16

Is there any way to set up a hotkey to change the opacity in either the terminal or iTerm? I usually use a low percentage opacity and it would be nice to be able to toggle on and off quickly.

EDIT: Cmd + U does essentially the same thing without some customizability

2 Answers2

20

cmd + u toggles the transparency.

DKo
  • 820
  • 1
  • 9
  • 19
6

You can use AppleScript to do that.

i.e. in iTerm (ver. 2.9+) you can use the following to set all windows/sessons to 50% transparency:

tell application "iTerm"
    repeat with aWindow in windows
        tell aWindow
            tell current session
                set transparency to 0.5
            end tell
        end tell
    end repeat
end tell

Save that to a file and run it from the cmd-line via:

osascript scriptname.scpt

You could also drop it into Automator.app and set it up to run via a Hot-key combo..

Assuming you can do the same in Terminal.app, open up the AppleScript Dictionary for it and look at setting window properties/transparency...

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
  • I get the following when trying your script in iTerm2: `execution error: iTerm got an error: Can’t set current session of item 1 of every window to 0.0. (-10006)` Any ideas? – f1lt3r Feb 23 '16 at 20:29
  • Which version of iTerm are you using? I just retested it with `Build 2.9.20160206` and it works fine. – SushiHangover Feb 23 '16 at 21:24
  • 2
    I am using version, 2.1.4 which is newest (this is iTerm2 not iTerm). `Cmd + U` works for me. I also set up the same for VIM (`Cmd+U`) so I can watch things in the background while I code. – f1lt3r Feb 24 '16 at 15:38
  • You are using an the `old` version of iTerm2, the AppleScript that I listed is for newer (beta) 2.9.x version. http://iterm2.com/downloads.html – SushiHangover Feb 24 '16 at 15:59
  • Thanks, I will look into that. – f1lt3r Feb 24 '16 at 18:36