Skip to content

Instantly share code, notes, and snippets.

@mattpowell
Created July 26, 2011 06:37
Show Gist options
  • Save mattpowell/1106128 to your computer and use it in GitHub Desktop.
Save mattpowell/1106128 to your computer and use it in GitHub Desktop.
shell alias/fn's/etc...
function ssh() {
#save all args (makes it easier to pass to ssh later)
local all_args=$*
#save path to ssh exec in current $PATH
local ssh_path=$(which ssh)
# host is second to last arg. see ssh -h
local host=${@:(-2):1}
#### color codes for tput ####
# setaf=foreground, setab=background
# 0 Black
# 1 Red
# 2 Green
# 3 Yellow
# 4 Blue
# 5 Magenta
# 6 Cyan
# 7 White
# sgr0 reset
##############################
#### Or if you're on a Mac ####
# you can use an AppleScript to
# change to a different Terminal
# setting. I use Pro (white/black)
# by default, but jump to a custom
# one called 'mpowell-md' which
# is a shade of red when connecting
# to mpowell-md
###############################
case $host in
# can use basic regex here
*mpowell\-md*)
# osascript -e "tell application \"Terminal\" to set current settings of first window to settings set named \"mpowell-md\""
tput setaf 2;#green
;;
# default case
*)
# could default to setting it back to Pro, etc...
# osascript -e "tell application \"Terminal\" to set current settings of first window to settings set named \"Pro\""
;;
esac
eval "$ssh_path $all_args"
tput sgr0;#reset
#osascript -e "tell application \"Terminal\" to set current settings of first window to settings set named \"Pro\""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment