Skip to content

Instantly share code, notes, and snippets.

@treyd
Last active March 31, 2017 23:27
Show Gist options
  • Select an option

  • Save treyd/92f57d04c9965eca545460a2345a85cf to your computer and use it in GitHub Desktop.

Select an option

Save treyd/92f57d04c9965eca545460a2345a85cf to your computer and use it in GitHub Desktop.

Revisions

  1. treyd revised this gist Mar 31, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ssh-colorize
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,8 @@ if [[ "$@" =~ ss-platform ]]; then
    elif [[ "$@" =~ ss-support ]]; then
    set_term_bgcolor 0 40 0
    # add more host defs here. can be hostnames or ~/.ssh/config entries
    #
    # include the following if you want to highlight *any* ssh session
    else
    set_term_bgcolor 0 0 20
    fi
  2. treyd revised this gist Mar 31, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ssh-colorize
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,8 @@ if [[ "$@" =~ ss-platform ]]; then
    elif [[ "$@" =~ ss-support ]]; then
    set_term_bgcolor 0 40 0
    # add more host defs here. can be hostnames or ~/.ssh/config entries
    else
    set_term_bgcolor 0 0 20
    fi

    ssh $@
  3. treyd revised this gist Mar 31, 2017. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions ssh-colorize
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,7 @@
    # (2) set: alias ssh=~/bin/ssh-colorize
    # (3) do: chmod +x ~/bin/ssh-colorize
    #
    # Inspired from http://talkfast.org/2011/01/10/ssh-host-color
    # Fork from https://gist.github.com/773849
    #
    # Forkd from https://gist.github.com/thomd/956095

    set_term_bgcolor(){
    local R=$1
    @@ -27,7 +25,7 @@ if [[ "$@" =~ ss-platform ]]; then
    set_term_bgcolor 40 0 0
    elif [[ "$@" =~ ss-support ]]; then
    set_term_bgcolor 0 40 0
    # add more host defs here
    # add more host defs here. can be hostnames or ~/.ssh/config entries
    fi

    ssh $@
  4. treyd renamed this gist Mar 31, 2017. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions ssh-host-color.sh → ssh-colorize
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    #!/bin/bash
    #
    # (1) copy to: ~/bin/ssh-host-color
    # (2) set: alias ssh=~/bin/ssh-host-color
    # (1) copy to: ~/bin/ssh-colorize
    # (2) set: alias ssh=~/bin/ssh-colorize
    # (3) do: chmod +x ~/bin/ssh-colorize
    #
    # Inspired from http://talkfast.org/2011/01/10/ssh-host-color
    # Fork from https://gist.github.com/773849
    @@ -13,7 +14,7 @@ set_term_bgcolor(){
    local B=$3
    /usr/bin/osascript <<EOF
    tell application "iTerm"
    tell the current terminal
    tell the current window
    tell the current session
    set background color to {$(($R*65535/255)), $(($G*65535/255)), $(($B*65535/255))}
    end tell
    @@ -22,10 +23,11 @@ end tell
    EOF
    }

    if [[ "$@" =~ thomd ]]; then
    if [[ "$@" =~ ss-platform ]]; then
    set_term_bgcolor 40 0 0
    elif [[ "$@" =~ git ]]; then
    elif [[ "$@" =~ ss-support ]]; then
    set_term_bgcolor 0 40 0
    # add more host defs here
    fi

    ssh $@
  5. @thomd thomd revised this gist May 4, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions ssh-host-color.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,9 @@
    # (1) copy to: ~/bin/ssh-host-color
    # (2) set: alias ssh=~/bin/ssh-host-color
    #
    # Inspired from http://talkfast.org/2011/01/10/ssh-host-color
    # Fork from https://gist.github.com/773849
    #

    set_term_bgcolor(){
    local R=$1
  6. @thomd thomd renamed this gist May 4, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion set_iTerm_background.sh → ssh-host-color.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash
    #
    # alias ssh=/some/bin/ssh-host-color
    # (1) copy to: ~/bin/ssh-host-color
    # (2) set: alias ssh=~/bin/ssh-host-color
    #

    set_term_bgcolor(){
  7. @thomd thomd revised this gist May 4, 2011. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions set_iTerm_background.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,7 @@
    #!/usr/local/bin/bash
    #!/bin/bash
    #
    # alias ssh=/some/bin/ssh-host-color
    #

    set_term_bgcolor(){
    local R=$1
    @@ -15,15 +18,12 @@ end tell
    EOF
    }

    #

    if [[ "$@" =~ production.server ]]; then
    set_term_bgcolor 20 0 0
    elif [[ "$@" =~ staging.server ]]; then
    set_term_bgcolor 0 20 0
    if [[ "$@" =~ thomd ]]; then
    set_term_bgcolor 40 0 0
    elif [[ "$@" =~ git ]]; then
    set_term_bgcolor 0 40 0
    fi

    ssh $@


    set_term_bgcolor 0 0 0
  8. @pol pol revised this gist Jan 11, 2011. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions set_iTerm_background.sh
    Original file line number Diff line number Diff line change
    @@ -21,8 +21,9 @@ if [[ "$@" =~ production.server ]]; then
    set_term_bgcolor 20 0 0
    elif [[ "$@" =~ staging.server ]]; then
    set_term_bgcolor 0 20 0
    else
    set_term_bgcolor 0 0 0
    fi

    ssh $@
    ssh $@


    set_term_bgcolor 0 0 0
  9. @pol pol revised this gist Jan 11, 2011. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions set_iTerm_background.sh
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,12 @@ EOF

    #

    if [[ $RAILS_ENV =~ production ]]; then
    if [[ "$@" =~ production.server ]]; then
    set_term_bgcolor 20 0 0
    elif [[ $RAILS_ENV =~ development ]]; then
    elif [[ "$@" =~ staging.server ]]; then
    set_term_bgcolor 0 20 0
    else
    set_term_bgcolor 0 0 0
    fi
    fi

    ssh $@
  10. @pol pol created this gist Jan 11, 2011.
    26 changes: 26 additions & 0 deletions set_iTerm_background.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/usr/local/bin/bash

    set_term_bgcolor(){
    local R=$1
    local G=$2
    local B=$3
    /usr/bin/osascript <<EOF
    tell application "iTerm"
    tell the current terminal
    tell the current session
    set background color to {$(($R*65535/255)), $(($G*65535/255)), $(($B*65535/255))}
    end tell
    end tell
    end tell
    EOF
    }

    #

    if [[ $RAILS_ENV =~ production ]]; then
    set_term_bgcolor 20 0 0
    elif [[ $RAILS_ENV =~ development ]]; then
    set_term_bgcolor 0 20 0
    else
    set_term_bgcolor 0 0 0
    fi