Open new Terminal tab in current directory (updated!)

This is an updated shell script / AppleScript for opening a new tab in your current directory (or the specified directory). The last version was for the pre-tabbed version of Terminal.

#!/bin/sh –

if [ $# -ne 1 ]; then

/usr/bin/osascript <<-EOF
activate application "Terminal"
tell application "System Events"
    keystroke "t" using {command down}
end tell
tell application "Terminal"
    repeat with win in windows
            if get frontmost of win is true then
                do script "cd $PATHDIR; clear" in (selected tab of win)
            end if
        end try
    end repeat
end tell

  • Pete

    Ach, it works, but initialising AppleScript is so slow…

  • springrider

    works like a charm, looking for this for a long time, thanks!

  • Anonymous

    I had to change the osascript call to `arch -i386 osascript` because it was crapping out a bunch of errors.  Now it works like a charm.  And there is probably a better solution to this now… no?