atom-terminal-tab icon indicating copy to clipboard operation
atom-terminal-tab copied to clipboard

Show existing terminal if not active

Open rapgenic opened this issue 7 years ago • 8 comments

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:

  1. Open a new terminal if it doesn't exist
  2. 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)
  3. If a terminal exists and it's focused open a new one next to it

one command to rule them all :)

rapgenic avatar Jun 27 '17 10:06 rapgenic

This is a great suggestion! I will work on implementing this shortly.

jsmecham avatar Jun 27 '17 14:06 jsmecham

This goes right along with https://github.com/jsmecham/atom-terminal-tab/issues/17

austincondiff avatar Jun 27 '17 15:06 austincondiff

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?

austincondiff avatar Jun 27 '17 15:06 austincondiff

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.

rapgenic avatar Jun 27 '17 19:06 rapgenic

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?

austincondiff avatar Jun 27 '17 20:06 austincondiff

Let's sum up, there would be two commands:

  • terminal:open: mapped to cmd-shift-t in the workspace, whose behaviour is:

    1. Open a new terminal if it doesn't exist
    2. If a terminal exists but it's not focused just show it (if hidden) or focus it
    3. 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 to cmd-n (but also to cmd-shift-t for consistency with the terminal: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 :)

rapgenic avatar Jun 27 '17 21:06 rapgenic

@jsmecham are you working on this, may I give a hand?

sonhanguyen avatar Oct 03 '17 12:10 sonhanguyen

This should be considered alongside #66 and #81.

jsmecham avatar Apr 21 '18 05:04 jsmecham