summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-07-04 15:38:04 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-07-04 15:38:04 -0700
commitd0a7c13df28fec06a6d092d1c1ba2ac2ce11c85c (patch)
tree84f2c106b335d50671e6dc79d83eff87167e02d1
parent98a2554ee29415a5cf7965114975b875d0d3f74a (diff)
Adding a hostname grabbing regex to sshclip
-rwxr-xr-xsshclip7
1 files changed, 5 insertions, 2 deletions
diff --git a/sshclip b/sshclip
index 4a4de8d..ebabcf1 100755
--- a/sshclip
+++ b/sshclip
@@ -3,10 +3,13 @@
# Open a SSH session to the hostname in the clipboard
# Requires the xclip package to be installed.
-HOSTNAME=$(xclip -out|cut -d' ' -f1)
+getSelection() {
+ HOSTNAME=$(xclip -out -selection $1|sed -re 's/(.*[[:space:]]|)([A-Za-z0-9][A-Za-z0-9.-]+\.[A-Za-z0-9.-]*[A-Za-z0-9]).*/\2/')
+}
+getSelection 'primary'
if [ -z "$HOSTNAME" ]; then
- HOSTNAME=$(xclip -out -selection secondary|cut -d' ' -f1)
+ getSelection 'secondary'
fi
if [ -n "$HOSTNAME" ]; then