#!/bin/sh # Open a SSH session to the hostname in the clipboard # Requires the xclip package to be installed. 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 getSelection 'secondary' fi if [ -n "$HOSTNAME" ]; then i3-sensible-terminal -e ssh $HOSTNAME & else notify-send "No hostname in clipboard" exit 1 fi