Skip to content

Instantly share code, notes, and snippets.

@ilstar
Created July 23, 2011 01:46
Show Gist options
  • Save ilstar/1100837 to your computer and use it in GitHub Desktop.
Save ilstar/1100837 to your computer and use it in GitHub Desktop.
batch open iTerm tab with same path
#!/usr/bin/osascript
#
# Install
# copy this file to a directory which is one of your system PATH
# chmod +x filename
#
# Usage
# rcd ~/Download 3
# argv 1: the path which you want to "cd"
# argv 2: the count of new tab.
#
# NOTE: this script only works for iTerm.
on run argv
tell application "iTerm"
set mypath to ("cd " & item 1 of argv)
set tab_count to (item 2 of argv as integer)
tell the first terminal
tell the last session
write text mypath
end tell
repeat with a from 1 to tab_count
launch session "Default Session"
tell the last session
write text mypath
end tell
end repeat
end tell
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment