Open iTerm tab in same directory.
UPDATE: You don’t need any AppleScript, there’s apparently already a preference in iTerm 2 (*doh!*, thanks to Robin Mehner for pointing it out). I’m leaving this up here in case the AppleScript comes in handy. That’ll teach me to ask the #lazyweb first.
A little AppleScript application to open a new iTerm tab in the directory you’re currently in.
I often want to open a new tab in iTerm 2 that launches in the same directory that the current tab is in so I whipped up a little AppleScript application to do just that. I launch it via a hotkey defined in an Alfred 2 workflow. I thought some of you mind also find it useful, so here it is:
tell application "iTerm"
activate current terminal
tell the current terminal
tell the current session
write text "pwd | pbcopy"
end tell
set newSession to (launch session "Default Session")
# For some reason, telling the new session something dummy like the next line speeds up the process greatly.
tell newSession to write ""
tell newSession to write text "cd `pbpaste`"
end tell
end tell
Downloads
- AppleScript application (53kb, zipped)
- AppleScript source (2kb, .scpt)
- Alfred Workflow (16kb, .alfredworkflow)
NB. If you download the Alfred Workflow, you will need to customise it based on where you saved the AppleScript application and what you want your hotkey to be.