Just a quick snippet I’m using to open a new tab in Terminal. It accepts a single, optional argument which will override cd’ing to the working directory.
#!/usr/bin/env bash if [[ $# -eq 0 ]]; then dir=`pwd` else dir=$1 fi /usr/bin/osascript \ -e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down" \ -e "tell app \"Terminal\" to do script \"cd $dir\" in front window" \ -e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"l\" using control down"
I’ve put the shell script in “/usr/local/bin” as this is in my $PATH. I’ve named the script “tab” so whenever in Terminal I can enter “tab” to open a new tab with the current working directory ready and waiting. Very useful when working with Rails and multiple shells.







