I spend the vast majority of my work day in the command line, and easily showing and hiding my terminal with TotalTerminal is a feature I could no longer do without.
There are several problems with TotalTerminal though. The biggest complaint I have with it is that you’re forced to use OSX’s built in Terminal.app, which is pretty inferior when compared to iTerm2. iTerm2 even comes with it’s own TotalTerminal-esque hotkey.
The iTerm2 hotkey works great most of the time, but it apparently just doesn’t work in fullscreen mode, which is important since I do most of my development on small screen and need the extra space. The answer to my problems is Quicksilver and a short AppleScript snippet.
If you’re not using Quicksilver already, you should. It’s a great way to quickly launch applications, find files, and more. In this case, we’ll be using it to run an AppleScript file when we press a hotkey.
1 2 3 4 5 6 7 8 9 10 11 | |
The code above will detect the currently selected application and switch to
iTerm2 if it’s not already selected. When iTerm2 is selected, it will switch to
Chrome instead. This is a good setup for me as a web developer, but you may
want to modify this behavior. I initially tried to have it just send
a Command+Tab (alt+tab for all you PC users) keystroke to go back to the
previous application, but was having issues getting it to work properly.
To have this script run on a keystroke, copy and paste the code above and save
it somewhere on your computer. Open up Quicksilver’s “Trigger”
preferences and add a new custom trigger to run the script you just saved.
I have Ctrl+; setup to toggle between iTerm2 and Chrome (I also have Ctrl
remapped to capslock).
If everything is setup right, you should now be able to press your hotkey and toggle between iTerm2 and Chrome!
As an aside, this was my first time playing with AppleScript, and I’m quite impressed. There’s a lot you can do with such a nice, readable syntax. I’ll probably end up writing more scripts in the future to automate/hack more of my workflow.