2

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.

7

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

#!/bin/bash
osascript /path/to/scpt/bgImgIterm.scpt

My current OSX version is 10.11.5 and iTerm2 version is 3.0.10

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.