0

I typically have multiple terminal sessions across different screens. Since opening the terminal is such a frequent task, I have a hotkey bound to open -b com.googlecode.iterm2 . with Karabiner-Elements. This way I can open a terminal from anywhere with one keypress.

Unfortunately if a terminal window is already open, this hotkey does not create a new window, but creates a new tab in existing windows. The existing window is often some long running "background" process like top or watch, meant to run undisturbed on a secondary screen while I do my work on the main screen. When a new tab is created in it, this causes problems for my workflow:

  • Hides the monitoring session, which I probably want to see
  • Opens the new terminal on the secondary screen, even if I had been working on the primary one
  • Moving the terminal to my main screen also moves the monitoring session to the main screen, so I have to move it back when done
  • Separating the tab requires finicky and tedious mouse dragging

These may seem like minor complaints, but I develop software and have to go in and out of terminals a lot. Depending on what I'm working on, I may need to open and close new terminals every few minutes, sometimes multiple times a minute. Reusing the same terminal is not really an option because often the terminals have distinct sessions (eg. TUI programs that run continuously, SSH to multiple different machines).

Is there a command I can bind that also creates a new iTerm2 window?

In theory I could command-tab to the terminal first and use a hotkey to make a new window. This has 2 problems:

  • Instead of one key press, I need to make several key presses to switch windows first.
  • Doesn't handle edge case where terminal is not running already.
2
  • Spaces is not designed to handle a single app across more than one Space/Desktop. That's going to be your major hurdle, though idk specifically about iTerm.
    – Tetsujin
    Mar 25 '20 at 18:31
  • @Tetsujin If I go to the Dock, right click the iTerm2 icon, and select "New Window", it creates a new window on the correct screen as I would expect. The problem is that this requires me to use the mouse, so I was hoping there's a command that does it.
    – Donentolon
    Mar 25 '20 at 19:28
2

This is already built into iTerm2. See the Hotkeys section in their documentation.

  • Show/hide all windows with a dedicated, system-wide hotkey
  • Create a dedicated hotkey window.

    In its simplest form, it's a system-wide terminal window that you can open with a hotkey.

You can find these options in Preferences -> Keys

OSXDaily has an excellent write up on this (with pictures)

1
  • This is not what the OP is asking for. This hotkey, while global, is assigned to a single terminal. If you press it repeatedly it will open and close a single terminal, not open new terminal windows.
    – PKKid
    Nov 23 '21 at 1:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .