Skip to content

Instantly share code, notes, and snippets.

@dgulino
Created January 25, 2013 23:08
Show Gist options
  • Save dgulino/4638756 to your computer and use it in GitHub Desktop.
Save dgulino/4638756 to your computer and use it in GitHub Desktop.
I've come up with a much better, simpler recipe to color my OSX Terminal session depending on the host I'm ssh-ing into. First, take a function with some cool BASH-only splitting and arrays and add that I found a way to address the current session in Applescript. Then add a one line way to enable bash ssh auto-complete when using the function. E…
ash() {
ARGS="$@"
IFS=" "
set -- $ARGS
ARGSARRAY=( $@ )
HOST=${ARGSARRAY[0]}
IFS="-"
set -- ${HOST}
MYARRAY=( $@ )
SERVERTYPE=${MYARRAY[0]}
ENVNAME=${MYARRAY[1]}
if [ "${ENVNAME}" = "pro" ]; then
if [ "${serverType}" = "p19" ]; then
PROFILE="Basic Green"
else
PROFILE="Basic Black"
fi
elif [ "${ENVNAME}" = "qa" ]; then
PROFILE="Basic Grey"
elif [ "${ENVNAME}" = "stage" ]; then
PROFILE="Man Page"
elif [ "${ENVNAME}" = "shadow" ]; then
PROFILE="Basic Blue"
else
PROFILE="Basic"
fi
echo "tell app \"Terminal\" to set current settings of first window to settings set \"${PROFILE}\"" | osascript
ssh "${ARGS}"
echo "tell app \"Terminal\" to set current settings of first window to settings set \"Basic\"" | osascript
}
complete -o default -o nospace -F _ssh ash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment