画面の色の変更
version 3.0 から Applescript による iTerm2 の操作方法が変更になりました.
新しいバージョンに対応したドキュメントによると, 以下の Applescript で変更可能になります.
tell application "iTerm2"
tell current session of current window
set background color to {$R, $G, $B}
end tell
end tell
ちなみに,set background color to {$R, $G, $B, $alpha}
といったように 4番目の引数 $alpha を渡すと透過度を変更できます.
ssh 毎に画面の色を変更する
例えば,自分は以下のように設定しています.
function set_term_bgcolor() {
local R=${1}*65535/255
local G=${2}*65535/255
local B=${3}*65535/255
/usr/bin/osascript <<EOF
tell application "iTerm2"
tell current session of current window
set background color to {$R, $G, $B}
end tell
end tell
EOF
}
function myssh() {
local R=0
local G=0
local B=0
case $1 in
"dev" ) R=40 G=0; B=0; shift ;;
"pro" ) R=0; G=40; B=0; shift ;;
"warn") R=40 G=40; B=0; shift ;;
*) R=0; G=0; B=30 ;;
esac
set_term_bgcolor $R $G $B
\ssh $@
set_term_bgcolor 0 0 0
}
alias ssh='myssh'
以下のように使うことができます.
ssh dev host # 背景赤
ssh pro host # 背景緑
ssh warn host # 背景黄色
ssh host # 背景青