Skip to content

Instantly share code, notes, and snippets.

@danielwestendorf
Last active March 18, 2019 14:25
Show Gist options
  • Save danielwestendorf/44420bf23b4368963d264e9618ad5a55 to your computer and use it in GitHub Desktop.
Save danielwestendorf/44420bf23b4368963d264e9618ad5a55 to your computer and use it in GitHub Desktop.
# install bash-preexec
# curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
# Add this (or source it) from your ~/.bashrc
[ -n "$PS1" ] && source ~/.bash-preexec.sh
preexec() {
if echo "$1" | grep -q -E "prod|ssh" ; then
echo -e "\033]50;SetProfile=Prod\a" # iTerm2 profile change, call AS or other here
fi
if echo "$1" | grep -q -E "staging" ; then
echo -e "\033]50;SetProfile=Staging\a"
fi
}
precmd() {
echo -e "\033]50;SetProfile=Default\a" # Revert to default
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment