Change your zsh terminal's color scheme when you SSH into a server. Works while running on iTerm2.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

iTerm-2 SSH Color Scheme

If you want to change your iTerm2 ZSH shell's theme/color scheme when you SSH into a server, follow these directions below.

Create 2 Profiles:

*	Your personal preference theme (can be named anything)
*	SSH color theme (must be named SSH)

Go into your ~/.oh-my-zsh/custom directory and create a new file entitled iTerm2-ssh.zsh. Copy and paste the following or copy from the repo:

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() {
    echo -e "\033]50;SetProfile=$NAME\a"
    trap - INT EXIT

function colorssh() {
    if [[ -n "$ITERM_SESSION_ID" ]]; then
        trap "tab-reset" INT EXIT
        if [[ "$*" =~ "web*|production|ec2-.*compute-1" ]]; then
            tabc SSH
    ssh $*
compdef _ssh tabc=ssh

alias ssh="colorssh"

The breakdown of this code:

function tabc() grabs the ssh name after the command $ ssh is entered. This changes the SetProfile name to ssh.

tab-reset() is responsible for when you exit the ssh session to return back to a profile name of your choosing. Remember to create a custom profile name and replace the YOUR_CUSTOM_PROFILE_NAME_HERE with your profile name.

colorssh determines when to change the SetProfile name. Currently it will changes to the ssh profile when the following values exist after $ ssh.

-	web *
-	production
-	ec2-.*compute-1

Go here for a library of iTerm2 color themes to choose from.

Make sure to start a new tab to see the results.