ITerm を最大化すると透明度がゼロになっちゃうんですよね。
せっかく John’s Background Switcher | John's Adventures を使って背景を変えてるのに、ちょっと寂しい……。
とゆーワケで、空の enter を押すたびに iterm の背景を変えるスクリプトを書きました。
iterm.zsh
# -*- sh -*-
image_index=1
WALLPAPERS_PATH=`find ~/Library/Containers -name Wallpapers`
change_background_picture() {
if [ `tput cols` -eq 80 ]
then
osascript -e "tell application \"iTerm\"
set current_terminal to (current terminal)
tell current_terminal
set current_session to (current session)
tell current_session
delete background image path
end tell
end tell
end tell"
zle accept-line
return
fi
image_list=($WALLPAPERS_PATH/*)
if [ -z "$BUFFER" ]
then
image_path=$image_list[$(( $RANDOM % $#image_list + 1 ))]
osascript -e "tell application \"iTerm\"
set current_terminal to (current terminal)
tell current_terminal
set current_session to (current session)
tell current_session
set background image path to \"$image_path\"
end tell
end tell
end tell"
zle reset-prompt
zle accept-line
else
zle accept-line
fi
}
zle -N change_background_picture
bindkey '^m' change_background_picture
.zshrc
に以下のように追加してください。
source $ZDOTDIR/iterm.zsh
最大化されてるか否かは、カラム数が 80 であるか否かで判断してます。
最大化をやめて、カラム数が 80 になった状態で空の enter を押すと、背景は削除されます。