1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iterm2をアップデートしたら背景画像が動的に変わらなくなったので。

Last updated at Posted at 2016-09-24

#背景画像を動的に変えて楽しむ

エンターを押すたびに背景画像を切り替えて飽きないようにしていた。

最近、アップデートしたらスクリプトが動かなくなったので修正した。
~/.zshrc


image_list1=(`find '/Users/hoge/Pictures/zsh' -name "*.png"  -o -name "*.jpg" -o -name "*.gif"`)
image_index=1
bg() {
     if [ -z "$BUFFER" ]; then
        if test $image_index -eq 10; then
            image_index=1
        else
            image_index=$(( $image_index + 1 ))
        fi
            image_path=$image_list1[$image_index]
            osascript -e "tell application \"iTerm\"
                            tell current window
                                tell current session
                                    set background image to \"$image_path\"
                                end tell
                            end tell
                          end tell"
            zle reset-prompt
            zle accept-line
    else
        zle accept-line
    fi
}
zle -N bg
bindkey '^m' bg

とりあえず、コレで動いたのでメモ

各人、'/Users/hoge/Pictures/zsh'は変えてください

indexが10まででループしてあるので、枚数が違う人は

if test $image_index -eq 10; then

の行の10を変えてください。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?