Skip to content

Instantly share code, notes, and snippets.

@dgurkaynak
Last active March 25, 2021 16:16
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 dgurkaynak/f2259636d58b3b9408cd3ad8aeb1e640 to your computer and use it in GitHub Desktop.
Save dgurkaynak/f2259636d58b3b9408cd3ad8aeb1e640 to your computer and use it in GitHub Desktop.

Changing iTerm2 theme on SSH for oh-my-zsh

Put following line into your .zshrc

set_iterm_profile() { echo -e "\033]50;SetProfile=$1\a" }

Put colorssh.zsh file into ~/.oh-my-zsh/custom/ folder.

# Create a file inside ~/.oh-my-zsh/custom/
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi
# if you have trouble with this, change
# "Default" to the name of your default theme
echo -e "\033]50;SetProfile=$NAME\a"
}
function tab-reset() {
NAME="Default"
echo -e "\033]50;SetProfile=$NAME\a"
}
function colorssh() {
if [[ -n "$ITERM_SESSION_ID" ]]; then
trap "tab-reset" INT EXIT
tabc SSH
fi
ssh $*
}
compdef _ssh colorssh=ssh
alias ssh="colorssh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment