diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-07-04 15:38:04 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-07-04 15:38:04 -0700 |
commit | d0a7c13df28fec06a6d092d1c1ba2ac2ce11c85c (patch) | |
tree | 84f2c106b335d50671e6dc79d83eff87167e02d1 /sshclip | |
parent | 98a2554ee29415a5cf7965114975b875d0d3f74a (diff) |
Adding a hostname grabbing regex to sshclip
Diffstat (limited to 'sshclip')
-rwxr-xr-x | sshclip | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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 |