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
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
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.