Skip to content

Instantly share code, notes, and snippets.

@cartazio
Created April 17, 2011 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartazio/924342 to your computer and use it in GitHub Desktop.
Save cartazio/924342 to your computer and use it in GitHub Desktop.
new tab for iterm2
# First, get the directory for the new tab
if [[ $# == 0 ]]; then
ThisDirectory=$PWD
elif [[ $# == 1 && -d "$1" ]]; then
ThisDirectory="$@"
else
print "usage: ntab [directory]"
return 1
fi
osascript <<-eof
tell app "Finder"
activate
tell application "iTerm"
-- make new terminal
tell the front terminal
activate current session
launch session "Default Session"
tell the current session
write text "cd \"$ThisDirectory\""
end tell
end tell
end tell
tell application "Finder"
activate
end tell
tell application "iTerm"
activate
end tell
end tell
eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment