#!/bin/bash # Debug option set -o xtrace ( echo "Parsing URI..." # If there is an @ sign in uri parse it, uri is in the form of ssh://user@host or ssh://user@host:port if [[ "${1}" =~ "@" ]];then echo "In if statement" user=$(echo ${1} | awk -F// '{ print $2 }' - | awk -F@ '{ print $1 }' -) host=$(echo ${1} | awk -F// '{ print $2 }' - | awk -F@ '{ print $2 }' -| awk -F: '{ print $1 }' -) host=${host%/} # Remove trailing slash (seems to be passed in URI) port=$(echo ${1} | awk -F: '{ print $3 }' -) [ -z "$port" ] && port="22" gnome-terminal -- ssh $user@$host -p $port # terminator -e "ssh $user@$host -p $port" # else $1 is in the form of ssh://host which uses our .ssh/config aliases else echo "In else" host=$(echo ${1} | awk -F// '{ print $2 }') host=${host%/} # Remove trailing slash (seems to be passed in URI) gnome-terminal -- ssh $user@$host -p $port # terminator -e "ssh $host" fi ) >> /tmp/ssh-handler 2>&1