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.
  • 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 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 at 19:28
1

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)

| improve this answer | |
  • Is this solution based on first focusing iTerm2, and then using its own built in "New Window" function? – Donentolon Mar 25 at 18:51
  • No. “System-wide” means just that... system-wide. Did you try it? – Allan Mar 25 at 18:52
  • Allan, why are you leaving passive aggressive comments on all my questions? I get the feeling you have some personal dislike against me, but if that is the case I don't understand why you spend your clearly valuable time on harassing me. – Donentolon Mar 25 at 19:16
  • 1
    I’m definitely not passive aggressive and any one who knows me will tell you that. I asked you that question because it appears you were looking to rebut prior to reading the documentation I linked or the solution I proposed. My questioning is designed to get you to stop and evaluate what’s being answered. If you take offense to that, then you need to look inwards to see what’s the catalyst causing you to be offended when people point things out to you – Allan Mar 25 at 19:30
  • So, once again.... did you try it? If I doesn’t work for you, it won’t bother me in the slightest. In fact, I’ll try to help find another solution. – Allan Mar 25 at 19:31

You must log in to answer this question.

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