Skip to content

Instantly share code, notes, and snippets.

@taiar
Forked from erangaeb/iTrem2-ssh.zsh
Created October 20, 2023 16:52
Show Gist options
  • Save taiar/06fb8784862680fa6612d14968fb8760 to your computer and use it in GitHub Desktop.
Save taiar/06fb8784862680fa6612d14968fb8760 to your computer and use it in GitHub Desktop.

Revisions

  1. @erangaeb erangaeb revised this gist Aug 21, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions iTrem2-ssh.zsh
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,6 @@ function colorssh() {
    }
    compdef _ssh tabc=ssh

    # creates an alias to ssh
    # when execute ssh from the terminal it calls to colorssh function
    alias ssh="colorssh"
  2. @erangaeb erangaeb revised this gist Aug 21, 2018. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions iTrem2-ssh.zsh
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,22 @@
    # tabc <profile name> do the profile change
    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"
    }

    # reset the terminal profile to Default when exit from the ssh session
    function tab-reset() {
    NAME="Default"
    echo -e "\033]50;SetProfile=$NAME\a"
    }

    # selecting different terminal profile according to ssh'ing host
    # tabc <profile name> do the profile change
    # 1. Production profile to production server (ssh eranga@production_box)
    # 2. Staging profile to staging server(ssh eranga@staging_box)
    # 3. Other profile to any other server(test server, amazon box etc)
    function colorssh() {
    if [[ -n "$ITERM_SESSION_ID" ]]; then
    trap "tab-reset" INT EXIT
  3. @erangaeb erangaeb created this gist Aug 21, 2018.
    28 changes: 28 additions & 0 deletions iTrem2-ssh.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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
    if [[ "$*" =~ "prod*" ]]; then
    tabc Production
    elif [[ "$*" =~ "staging*" ]]; then
    tabc Staging
    else
    tabc Other
    fi
    fi
    ssh $*
    }
    compdef _ssh tabc=ssh

    alias ssh="colorssh"