Skip to content

Instantly share code, notes, and snippets.

@jpfreire
Created August 20, 2020 18:03
Show Gist options
  • Save jpfreire/5c8db00567a39e7355cb0c930424c455 to your computer and use it in GitHub Desktop.
Save jpfreire/5c8db00567a39e7355cb0c930424c455 to your computer and use it in GitHub Desktop.
AppleScript to open new tab in current dir
-- Export the AppleScript as an aplication then enable it in System Preferences > Security & Privacy > Privacy > Accessibility
tell application "iTerm" to activate
tell application "System Events" to keystroke "pwd | pbcopy"
tell application "System Events" to key code 52
tell application "System Events" to keystroke "t" using command down
delay 2
tell application "System Events" to keystroke "cd \"`pbpaste`\" "
tell application "System Events" to key code 52
-- then you can use it in Spotlight (command + space bar)
-- same funcionality can be achieved using iterm profiles preferences:
-- Iterm > Preferences > Profiles > General > Working Directory > Reuse previous session's directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment