普段は気にする必要はないのですが,24bit 色サポートが iTerm のみなので Vim の設定で現在のターミナルを知る必要が生じました. 僕は日頃から tmux を常用しているのですが,ここで問題が1つあります.tmux は環境変数をクリアしてしまい,iTerm2 上であっても tmux 起動後は $TERM_PROGRAM が Apple_Terminal になってしまいます.これは iTerm2 が起動時に行っている $TERM_PROGRAM の上書きが行われないためです.なので,.tmux.conf に明示的に「$TERM_PROGRAM を tmux 起動後のシェルに forward してね」という設定を書く必要があります.tmux は ssh 関連の環境変数や $DISPLAY などいくつかはデフォルトで環境変数をセットしてくれますが,それ以外は手で .tmux.conf