summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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