General Computing
terminal shell desktop-customization iterm2
Updated Thu, 15 Sep 2022 04:17:36 GMT

iTerm2 (OS X) change background image for current window from shell?

iTerm2 allows to set a background image or color, either for the current window or the default (used for all new windows).

However, can I also set the current window's background image or color from the command line? I.e. is there some magic iTerm2 terminal command to set the active window's background?

I would love to use this in scripts to change the background reflecting that I'm logged in at certain remote systems, to make an automatic visual difference between local or remote shells, or even use specific backgrounds for ssh sessions on specific servers.


I was just trying to do exactly the same :-). Here you go, using AppleScript and bit of bash if you like.

--this goes inside for example bgImgIterm.scpt--
tell application "iTerm2"
  tell current session of current window
    set background image to "/path/to/img/img.jpg" 
  end tell
end tell

then you can run it inside bash like

osascript /path/to/scpt/bgImgIterm.scpt

My current OSX version is 10.11.5 and iTerm2 version is 3.0.10

Comments (1)