Skip to content

Instantly share code, notes, and snippets.

@amykyta
Created August 2, 2017 18:35
Show Gist options
  • Save amykyta/270d2bf050f5c3b450b49f67b4c2578f to your computer and use it in GitHub Desktop.
Save amykyta/270d2bf050f5c3b450b49f67b4c2578f to your computer and use it in GitHub Desktop.
colored iterms by box sshed into

so here is my setup, I have a ~/.ssh/config file with this in it

Host staging
  HostName staging.bondstreet.com
  User ubuntu

Host prod
  HostName bondstreet.com
  User ubuntu

That way I can ssh by alias (ssh prod / ssh staging / ssh dev) and not use vagrant for ssh.

Then I add this to my .bash_profile

    $HOME/themedssh.sh $*
}

alias ssh="themedssh"

and themessh.sh in $HOME is


function tabc() {
    NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi
    echo -ne "\033]50;SetProfile=$NAME\a"
}

function tabreset() {
    NAME="Default"
    echo -ne "\033]50;SetProfile=$NAME\a"
}

trap tabreset INT EXIT

if [[ "$1" = "prod" ]]; then
    tabc Prod
elif [[ "$1" = "staging" ]]; then
    tabc Staging
else
    tabc
fi

ssh $*

It selects an iterm2 profile based on the alias name ssh staging so those are necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment