terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Feature Request: Ability to change what key/key sequence reopens or closes a profile session

Open datdamnmachine opened this issue 2 years ago • 3 comments

Description of the new feature/enhancement

This feature request is related to this feature request:

https://github.com/microsoft/terminal/issues/4379

Essentially, the ability to customize what key/key sequences reopens or closes a profile session. Currently Ctrl+D will close the terminal after exit and "Enter" will restart it. I would like to customize it so that "r" will restart the session and "<Return>" or "<Enter>" will close the session for good. This is what MobaXterm uses and it would be nice to have it consistent as I use both regularly.

Proposed technical implementation details (optional)

Something like this in the json file:

"closeOnExit": "never", { "closeKey": "<Enter>", "reopenKey": "r" }

datdamnmachine avatar Jan 21 '24 00:01 datdamnmachine

Good catch! Thanks for filing this.

carlos-zamora avatar Jan 24 '24 22:01 carlos-zamora

Can i help on this one?

skywalker290 avatar Jan 26 '24 06:01 skywalker290

@skywalker290 We probably won't get to this ourselves, so we'd definitely appreciate the help!

I'd caveat all this with the fact that we'll need to brainstorm what the settings would look like in the actual json, so we may change how the setting is parsed on review. I'd guess something like the following would be a good start:

    "profiles": 
    {
        "defaults": 
        {
            "closeOnExit": "never",
            "closeKey": "ctrl+alt+q",
            "reopenKey": "r"
  • MTSM_PROFILE_SETTINGS in https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalSettingsModel/MTSMSettings.h#L78 already contains all the per-profile settings.
  • That'd need to get plumbed down to ControlCore: https://github.com/microsoft/terminal/blob/c669afe2a06c6db9a103e81a48cdc5b040d6fcff/src/cascadia/TerminalControl/ControlCore.cpp#L480-L497
  • More tricky: we'd have to find a way to also plumb those keys (or the stringification of them) into: https://github.com/microsoft/terminal/blob/c669afe2a06c6db9a103e81a48cdc5b040d6fcff/src/cascadia/TerminalConnection/ConptyConnection.cpp#L457-L470 which is where the message is actually printed

zadjii-msft avatar Feb 01 '24 17:02 zadjii-msft

Json format would help with this we can put data into one json structure and send it.

skywalker290 avatar Feb 23 '24 20:02 skywalker290