From d0a7c13df28fec06a6d092d1c1ba2ac2ce11c85c Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 4 Jul 2013 15:38:04 -0700 Subject: Adding a hostname grabbing regex to sshclip --- sshclip | 7 +++++-- 1 file 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 -- cgit v1.2.3