Skip to content

Instantly share code, notes, and snippets.

@sjpp
Last active October 17, 2019 15:22
Show Gist options
  • Save sjpp/e732506281def7ef17ed8ef3b3c575d6 to your computer and use it in GitHub Desktop.
Save sjpp/e732506281def7ef17ed8ef3b3c575d6 to your computer and use it in GitHub Desktop.
# This code can be used as an ssh alias in order to get
# target hostname in title as well as changin background color
# Usage example: sss r user@host.domain.org
sss() {
case "$1" in
r ) _REMOTE_BGCOLOR="#2F0100" ;;
v ) _REMOTE_BGCOLOR="#003611" ;;
n ) _REMOTE_BGCOLOR="#111111" ;;
b ) _REMOTE_BGCOLOR="#002E51" ;;
* ) _REMOTE_BGCOLOR="#2F0100" ;;
esac
_ORIG_BGCOLOR="#282A36"
_ORIG_TERMTITLE="Terminal"
echo -e "\033]11;$_REMOTE_BGCOLOR\a"
ssh -A -C $2 -t 'echo -ne "\033]0;$(echo $HOSTNAME | tr \[\:lower:] \[\:upper:])\007"; eval $SHELL'
echo -e "\033]11;$_ORIG_BGCOLOR\a"
echo -e "\033]2;$_ORIG_TERMTITLE\007"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment