How to switch terminal settings using a keyboard shortcut

keyboardsettingsterminal

Usually I need different settings in my terminal depending on what I'm working on. For example, change the opacity to see some info on the back.

I think an option is to set different setting schemas, and then switch between them with a keyboard shortcut. Any ideas on how to achieve this?

Best Answer

You can do this via Terminal's AppleScript interface, for example to set the background colour of the first tab in the first window to green:

tell application "Terminal"
    set tabsettings to current settings of tab 0 of window 0
    set background color of tabsettings to {0, 32768, 0} -- colours are 16-bit
end tell

That's the good news. The bad news is that the background opacity is not exposed to AppleScript in Lion (this seems like an oversight by Apple). You can change pretty much everything else like this though (see the Library in the AppleScript Editor for the full list). There are a few crazy AppleScripts out there that adjust the background opacity by emulating keypresses to Terminal, but that approach is too horrible to even link to.

Once you have the AppleScript code to change the settings to your liking there are many ways of binding your script to a key.