atom-terminal-tab
atom-terminal-tab copied to clipboard
Show existing terminal if not active
At the moment the open terminal command opens a new pane every time it is triggered. It would be very useful to have the default open command:
- Open a new terminal if it doesn't exist
- If a terminal exists but it's not focused just show it (if hidden) or focus it (I have noticed that most of the times you don't want to create a new terminal, just open the only one you actually use)
- If a terminal exists and it's focused open a new one next to it
one command to rule them all :)
This is a great suggestion! I will work on implementing this shortly.
This goes right along with https://github.com/jsmecham/atom-terminal-tab/issues/17
Sometimes additional terminal tabs are required for a project. I typically have three open per project. As long as it is clear what the user is doing this would be perfect. I might suggest a 'Open terminal' and 'Open new terminal' command. Thoughts?
Of course having another command to open a new terminal in any case may be fine, but I don't think it is really necessary.
Let's imagine for example you want to open three terminals.
What you do now: press cmd-shift-t
three times
What would you do with the new 'open' command: again press cmd-shift-t
three times
In fact the first time there is no terminal, so it will be created and focused. Then when you type again the keystroke your terminal is already focused (that's the active panel and you can directly write on it), so it won't reopen the existing terminal, but create a new one, and the same for the third.
Anyway we must say that such logic may be a bit difficult to get for an end user, so another possibility could be having two commands (as you suggested): terminal:open
and terminal:open-new
, which are both mapped to the same keystroke (cmd-shift-t
) but with different selectors:
terminal:open
would be mapped to cmd-shift-t
in atom-workspace
terminal:open-new
would be mapped to cmd-shift-t
only in terminal-view
In this case the behaviour of the cmd-shift-t
keystroke would be the same as in the first case, but in the command palette you would find both commands, too, if you want to do something different from what a "normal" user would do, such as opening many new terminals from different scopes.
I see. Consider this. In the Atom workspace when you are editing a file, to create a new tab or new file you would press cmd+n
. In my opinion, when you have a terminal focused, 'cmd+n' should do the same and create a new terminal tab. If you have a file in focus and want to open a terminal tab if one is not already created or focus the last already existing tab if one or more has already been created, you would press cmd+shift+t
. I suppose the same command could open a new terminal tab as well if a terminal view is already in focus. Any objections?
Let's sum up, there would be two commands:
-
terminal:open
: mapped tocmd-shift-t
in the workspace, whose behaviour is:- Open a new terminal if it doesn't exist
- If a terminal exists but it's not focused just show it (if hidden) or focus it
- If many terminals exist but are not focused show or focus the last used one
-
terminal:open-new
: mapped for consistency with atom default keybindings tocmd-n
(but also tocmd-shift-t
for consistency with theterminal:open
command) in the terminal tab, which just opens a new terminal in any case.
If I understood well, I am perfectly fine with it :)
@jsmecham are you working on this, may I give a hand?
This should be considered alongside #66 and #81.