Skip to content

Instantly share code, notes, and snippets.

@Ketrel
Created January 28, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ketrel/606638e09ce2e3bfbfa35ad625083af6 to your computer and use it in GitHub Desktop.
Save Ketrel/606638e09ce2e3bfbfa35ad625083af6 to your computer and use it in GitHub Desktop.
SSH Connect Shortcut
#!/bin/sh
e="\033"
clu(){
if [ ! -z ${1} ] && [ $(tput colors) -ge 8 ]; then
printf "${e}[${1}m"
fi
}
prog=""
default="server"
pathmod="/local"
if [ -z ${1} ]; then
printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Invalid Use Of Script"
exit 1
fi
#-------------------#
if [ "${1}" = "local" ] || [ "${1}" = "remote" ]; then
prog="${default}"
pathmod="/${1}"
else
prog="${1}"
fi
#-------------------#
if [ ! -z ${2} ] && ([ "${2}" = "local" ] || [ "${2}" = "remote" ]); then
pathmod="/${2}"
elif [ ! -z ${2} ]; then
printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Invalid Use Of Script"
exit 1
fi
#-------------------#
if [ -f "$HOME/Scripts/sshcon_scripts${pathmod}/${prog}" ]; then
. "$HOME/Scripts/sshcon_scripts$pathmod/${prog}"
else
printf -- "---$(clu '41;1') %b $(clu 0)---\n" "Specified Connection Command Invalid"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment