Vscode: Integrated Terminal : Allow Renaming sessions

Created on 1 Aug 2016  路  31Comments  路  Source: microsoft/vscode

Please add a feature to rename sessions in the integrated terminal.
Usually one opens multiple terminal sessions using the same command like ssh. Then all these sessions are called ssh in the dropdown. Please allow to rename the session, so that its easy to choose.

feature-request help wanted integrated-terminal on-testplan

Most helpful comment

I would like to see a new button near the dropdown. Something like my screenshot. Also a command when you are in the terminal like ctrl+shift+r or f2 would be nice.

button example:
screenshot from 2016-08-04 10 22 23

All 31 comments

@stevencl @bgashler1 thoughts on this from UX side? I was thinking something like this would be quite cumbersome as you would have to do it whenever you launch a new terminal instance.

I would expect it would be optional. Just a quick thought but could you right click on the dropdown and choose a rename command?

I would like to see a new button near the dropdown. Something like my screenshot. Also a command when you are in the terminal like ctrl+shift+r or f2 would be nice.

button example:
screenshot from 2016-08-04 10 22 23

If the goal is to distinguish between different terminals, how about just automatically showing the last command run in each terminal? That way the user wouldn't even have to bother renaming if they just want to be bale to distinguish between multiple terminals (assuming that they aren't running the same command in every terminal).

If we have to expose an action, right click probably isn't the best approach as it is a little unusual to right click on a drop down. Thinking of this like a regular combobox though, perhaps just single clicking inside the drop down could highlight the text which the user could then replace.

I'm reluctant to add more buttons as that just adds weight and takes up space. I'd definitely expect that we should have some keyboard bindings for it.

For me it is mainly to distinguish the different terminals. So for me personally showing the last ran command is also fine.

Right clicking the terminal could also be an option, there's already a context menu there.

Also another piece of information I feel is missing is the current number of terminals, integrating everything into the dropdown could get messy, eg. "2/3: /bin/bash (gulp watch)"

For UX I would like:

  • If you hover over session name in dropdown (or new edit box beside the dropdown or beside "TERMINAL") the mouse pointer turns to text cursor. You can select and rename the session easily
  • Key binding for a command to rename which automatically moves focus / cursor to a fully selected name so you can immediately type a new one (or modify the selection to augment the existing name).
  • In either case enter or some other key binding "saves" and returns focus and cursor to the terminal prompt

It would also be nice if it was possible to launch terminals with a specific name to leave room for extensions which could allow you to organize and launch standard sessions. I'm not sure if this is already possible.

With the "last run command" option would you display the full command line or just the command?

Particularly when using Go, there are good reasons to have multiple terminals using the same "command" since many Go tools start with "go" ("go build", "go test", "go tool pprof", etc...). I'll often have an active profiling session open in one terminal while running builds / tests in another session. Unfortunately they're both the same "command" ("go").

I would say displaying the last run command is useful, but doesn't satisfy the same requirements as explicitly allowing renaming sessions. I would treat it as separate feature request to this one.

Going by the suggestions made, I believe there are two points this RFE should consider.

  1. [Default Mode] The dropdown should always display last command run (truncated). Hovering over the dropdown can display the full text.
  2. [Custom Mode] In case the user wants a custom name, they can right click the dropdown to make inline edits. Thereafter, the new input will be set as the default for that terminal.

Much needed!

In addition to the context menu (which I still think is a bit unusual) I was thinking of a design similar to this experience

dropdown

With the addition that I wouldn't make the text area editable by default. Perhaps guard against undesired edits by making the user click inside the area once to position a cursor at the end.

Another alternative design is that there is an

@stevencl I was speaking with @bgashler1 the other day about custom dropdowns for the panel x icon discussion. I don't think we do custom dropdowns currently which would be necessary for something like this, custom dropdowns are a decent chunk of effort to get right (fitting in with each OS, ensuring accessibility, etc.).

This also may not work if we want to put buttons inside the dropdown? Something to consider.

OK, how about we just start by automatically showing the last command run in each terminal? That seems to be the least we can do to help distinguish between the different terminals without requiring us to create custom controls to rename terminals.

Not sure if it's clear, but right now on platforms other than Windows it will show the currently running program, not just the shell name, So originally it's /bin/bash, but when I run gulp watch the label is changed to gulp as that's the active program. Once gulp watch exits it will go back to /bin/bash since that is now the active program.

There are some issues with trying to amend this string with the "last command run" as I don't think it's even possible to extract that information in a reasonable way given the array of shells that could be getting used and their syntax. Also commands are not composed and then sent to the shell, each _keystroke_ is converted into an ANSI key sequence and sent to the terminal at that time, depending on the key stroke the output on the actual terminal could be the key, it could be ignored, it could output garbage. There isn't a reliable way as far as I'm aware to get the command that is run from the terminal, only the last _program_ run.

The last _program_ to be run could also be a shell which would be super weird, consider zsh (/bin/bash) for example, launching zsh from bash.

Due to technical constraints on Windows it is always cmd.exe or whatever the shell name is, this discussion likely wouldn't be able to affect the Windows situation.

@stevencl @Tyriar I still think it's worth splitting "last run command" and "renaming the window" into two separate requests, even if the latter gets shelved due to the UX complexity.

I think there is value in both, but I don't believe last run command would meet requirements set out by the OP (@geevi correct me if I'm wrong!). It definitely wouldn't meet the requirements of the feature request that I was going to fill out before my duplicate search lead me to this one.

OK, in that case lets go with the other suggestion I made:

Another alternative design is that there is an entry at the bottom of the dropdown. If the user chooses this, they see a dialog box that displays the list of terminals. The user can select one, press a rename button, then type in the new name. It's quite cumbersome compared to the others but it puts the functionality out of the way meaning that people will be much less likely to rename a terminal

Another option could be to have a button and key binding that brings up a dialog similar to the find/replace dialog (and hopefully reuse the code) in the top right with the current window name, allowing you to rename.

Adding my support for this feature. Googled to see if there was an option after I opened five terminal sessions (Windows 10) and couldn't remember what was running in each session. They all say "cmd.exe" which doesn't help at all.

+1 for this feature request. Also, if we are working over SSH, just showing the last command run is not helpful. Hence it would be good to have a custom renaming.

+1 custom renaming
and custom order

+1

Update on this:

Opening this up to PRs, here's what we need:

  • A new command registered workbench.action.terminal.rename (see https://github.com/Microsoft/vscode/blob/ed91b067e075457791e5e523d25e110c57650a4b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts#L209)
  • The command will rename the currently active terminal instance, regardless if it is currently visible or not. You will need to get the active instance from TerminalService, add support for changing the terminal's name on TerminalInstance and ensure the _onTitleChanged event emitter gets triggered so the change is picked up by the panel and the dropdown is changed.
  • When the name is changed it should behave like when the title is set by the extension API and not change afterwards even if the terminal process tells it to change. So unregistering this will be required: https://github.com/Microsoft/vscode/blob/ed91b067e075457791e5e523d25e110c57650a4b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts#L470

Hey @Tyriar, I'm taking a look at this one. I've modified the TerminalInstance to support renaming, defined a new Action in terminalActions to expose it, and (I think) done the de-registration of the terminal process message handler for title changes. Do I also need to figure out how to present the UI for the user to enter the name of the terminal, or is the intent that I just PR this stuff and you guys work that out?

Thanks much!

@jammerware the command workbench.action.terminal.rename should present a quick open that lets the user enter the new name. To do that I think you want to use this https://github.com/Microsoft/vscode/blob/f1a8632778e4574cf07b3cb162aa998e4a51aebc/src/vs/platform/quickOpen/common/quickOpen.ts#L136

Should land in Insiders tomorrow thanks to @jammerware :+1: https://github.com/Microsoft/vscode/issues/28464

waiting for this feature in the stable version

Can it use the console caption as the default session name?

@zephrxx what's the console caption?

By caption I mean the highlighted part in the screen shot below.
capture

zephrxx ah, well I don't think we have access to that and also it would be too long for the dropdown. In https://github.com/Microsoft/vscode/issues/30152 we're looking into getting Windows closer to the Linux/macOS experience which shows the active program/shell:

  • If you launch powershell it will say "powershell"
  • If you launch cmd inside powershell, it will say "cmd"
  • If you launch npm install inside powershell, it will say "node"

Just press CTRL+SHIFT+P, then type TERMINAL RENAME, enter a name and press ENTER. :-D

Was this page helpful?
0 / 5 - 0 ratings