Jaymon / .bash

common bash functions and aliases I've written/accumulated over the years

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

open a new terminal window in the current terminal window's directory

Jaymon opened this issue · comments

NOTE Everything below is iTerm (iTerm2) specific!

you can get close to this with this command:

$ open . -a iTerm

But it opens a new tab.

I tried Applescript:

/usr/bin/osascript \
-e 'tell application "iTerm" to activate' \
-e 'tell application "System Events" to tell process "iTerm" to keystroke "n" using command down'

But I'm getting errors like:

Not authorized to send Apple events to iTerm
Not authorized to send Apple events to System Events

I've tried to add the right permissions in the Security and Privacy settings but I can't find a way to add permissions to iTerm under the automation section.

You can also go into iTerm's profile and click "edit profile", go to the Window tab and select "Open in a new window, never in a tab" but that seems like overkill, it feels like there must be a way to tell iTerm to do this programmatically, I tried passing in various flags using open but none of them have an effect, things like:

$ open . -a iTerm --args -n

Things that might be helpful:

search:

  • iterm "Not authorized to send Apple events to System Events"
  • iterm2 open new window not tab
  • open a new iterm shell from current iterm shell
  • iterm open new window not tab

Turns out my running instance of iTerm was in a bad state, once I restarted I could use applescript again and was able to get a working solution with applescript