New Terminal With Keyboard Shortcut on OS X Yosemite

In my typical Linux desktop I use ‘xbindkeys’ or my window manager’s built in keyboard shortcut preferences to set up an ‘open new terminal window’ keystroke (Super-Enter usually). When I moved to OS X for work last year, this was something I really missed, and it took me a while to find the simplest way to achieve it.

The solution is some simple applescript, which I put in ~/Library/Scripts/new-terminal.applescript

tell application "Terminal"
    do script ""
    activate
end tell

Then I installed the utility ‘FastScripts‘, at which point you can easily go into preferences and set up a global keyboard shortcut for your script.

Here’s another applescript I use to

  • Collect user input (name of server to ssh into in this case)
  • Run a utility bash script and pass in the argument
display dialog "Server name" default answer ""
set server_name to text returned of result
do shell script "ITERM_PROFILE=Default bash -l connect " & server_name