Last active
August 29, 2015 14:15
-
-
Save hatappo/e640703a395d51d45c1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# (1) copy to: ~/bin/ssh-host-color | |
# (2) set: alias ssh=~/bin/ssh-host-color | |
# | |
# Fork from https://gist.github.com/thomd/956095 | |
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 | |
} | |
reset_term_bgcolor(){ | |
set_term_bgcolor 0 0 0 | |
} | |
case "$@" in | |
"") reset_term_bgcolor;; # Reset color on no arguments | |
*-deploy*) set_term_bgcolor 40 0 40;; # Purple | |
*-adm*) set_term_bgcolor 40 0 40;; # Purple | |
dev-*) set_term_bgcolor 0 30 0;; # Green | |
stg-*) set_term_bgcolor 0 30 0;; # Green | |
prd-*) set_term_bgcolor 30 0 0;; # Red | |
trc-*) set_term_bgcolor 30 0 0;; # Red | |
ads-*) set_term_bgcolor 30 0 0;; # Red | |
*) set_term_bgcolor 40 40 40;; # Gray on others | |
esac | |
ssh $@ | |
reset_term_bgcolor |
tmux で画面分割した時に分割した画面それぞれの色を変えるのはできない。。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sshコマンドのpass入力をCtrl+cで抜けた場合は、リセット処理が呼ばれず背景色が戻らない。
その時は、引数無しで
ssh
と実行。リセット処理(とssh
コマンドのUsage表示)のみが実行される。