Ctrl+D to close a tab when profile has exited with error #17179

Closed
opened 2026-01-31 05:34:27 +00:00 by claunia · 8 comments
Owner

Originally created by @NewtonChutney on GitHub (Apr 7, 2022).

Description of the new feature/enhancement

Currently, in a Terminal tab, when a process doesn't exit cleanly, i.e., exits with an error code, the terminal profile can either be set to close anyway, or exit if only there isn't any error [error code 0]..
I would like to see a behaviour wherein the error code is shown, and later on a press of Ctrl+D, the tab closes..

This, would be similar to the behaviour in some Linux terminal apps, wherein a terminal exits to the exit code on Ctrl+D, and on another press of Ctrl+D, it exits.

This implementation would make the process of closing WSL profiles quicker and easier.. wherein users logout with Ctrl+D, and then can close the tab on another Ctrl+D, if the process exited with an error code.

Proposed technical implementation details (optional)

-Enhance the existing "Close only when process exits successfully" behaviour,
-or add a new behaviour option,
-or better yet, add a toggle for closing anyways upon Ctrl+D, which will enable it to work for the "Never close automatically" behaviour too! So that a user who might want to see the exit code 0, can please himself and then close the tab..😂

Originally created by @NewtonChutney on GitHub (Apr 7, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Currently, in a Terminal tab, when a process doesn't exit cleanly, i.e., exits with an error code, the terminal profile can either be set to close anyway, or exit if only there isn't any error [error code 0].. I would like to see a behaviour wherein the error code is shown, and later on a press of Ctrl+D, the tab closes.. This, would be similar to the behaviour in some Linux terminal apps, wherein a terminal exits to the exit code on Ctrl+D, and on another press of Ctrl+D, it exits. This implementation would make the process of closing WSL profiles quicker and easier.. wherein users logout with Ctrl+D, and then can close the tab on another Ctrl+D, if the process exited with an error code. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> -Enhance the existing "Close only when process exits successfully" behaviour, -or add a new behaviour option, -or better yet, add a toggle for closing anyways upon Ctrl+D, which will enable it to work for the "Never close automatically" behaviour too! So that a user who might want to see the exit code 0, can please himself and then close the tab..😂
Author
Owner

@zadjii-msft commented on GitHub (Apr 7, 2022):

I mean, you could always just bind Ctrl+D to closePane if you really wanted to always close it on Ctrl+D. That seems a little aggressive (esp. for things where you might actually want to press Ctrl+D, like in emacs or something).

Other discussions:

@zadjii-msft commented on GitHub (Apr 7, 2022): I mean, you could always just bind <kbd>Ctrl+D</kbd> to `closePane` if you really wanted to always close it on <kbd>Ctrl+D</kbd>. That seems a little aggressive (esp. for things where you might actually want to press <kbd>Ctrl+D</kbd>, like in emacs or something). Other discussions: * #11570 * #4379 * #3726
Author
Owner

@NewtonChutney commented on GitHub (Apr 7, 2022):

Yeah, nope, I don't want to close the pane with Ctrl+D..
I'd like to wait on the exit status and then when that's displayed.. A simple repeat of ctrl+D ought to close the pane..

I only want ctrl+D to close come into effect when the error code is shown after the process has exited.. And there isn't any context/process for WT to pass keypresses into..

For eg, I logout from WSL bash using ctrl+D, and the exit code shows in Windows Terminal, I guess the context is handed over to WT completely now.. So, in this moment, when the exit code is being shown, a ctrl+D ought to close the pane/tab/profile..

@NewtonChutney commented on GitHub (Apr 7, 2022): Yeah, nope, I don't want to close the pane with Ctrl+D.. I'd like to wait on the exit status and then when that's displayed.. A simple repeat of ctrl+D ought to close the pane.. I only want ctrl+D to close come into effect when the error code is shown after the process has exited.. And there isn't any context/process for WT to pass keypresses into.. For eg, I logout from WSL bash using ctrl+D, and the exit code shows in Windows Terminal, I guess the context is handed over to WT completely now.. So, in this moment, when the exit code is being shown, a ctrl+D ought to close the pane/tab/profile..
Author
Owner

@zadjii-msft commented on GitHub (Apr 8, 2022):

It's not a bad idea. Just need a simple way of expressing the action in json. We don't really have "conditional" keybindings right now, so it's not possible to say something like

{ 
  "command": { "action": "closePane" }, 
  "keys": "ctrl+d", 
  "when": { "connection.state": "closed" } 
},

Without that, we'd need some other way to express this conditional keybinding.

@zadjii-msft commented on GitHub (Apr 8, 2022): It's not a bad idea. Just need a simple way of expressing the action in json. We don't really have "conditional" keybindings right now, so it's not possible to say something like ```json { "command": { "action": "closePane" }, "keys": "ctrl+d", "when": { "connection.state": "closed" } }, ``` Without that, we'd need some other way to express this conditional keybinding.
Author
Owner

@DHowett commented on GitHub (Apr 9, 2022):

You know, I actually think this should be feature of ConptyConnection or somewhere around that layer. ^D is a common way to signal a shell to exit, and this is such a narrow case where having it rebindable just doesn't matter to me.

I like that we're thinking about making it extensible/contextual (you know how much I love my hobby horse, contextual key bindings!), but... in this case maybe the easy way is easier.

@DHowett commented on GitHub (Apr 9, 2022): You know, I actually think this should be feature of ConptyConnection or somewhere around that layer. <kbd>^D</kbd> is a common way to signal a shell to exit, and this is such a narrow case where having it rebindable just doesn't matter to me. I like that we're thinking about making it extensible/contextual (you know how much I love my hobby horse, contextual key bindings!), but... in this case maybe the easy way is easier.
Author
Owner

@zadjii-msft commented on GitHub (Apr 9, 2022):

I'm cool with that. Shouldn't be too hard to add.

@zadjii-msft commented on GitHub (Apr 9, 2022): I'm cool with that. Shouldn't be too hard to add.
Author
Owner

@sotteson1 commented on GitHub (Sep 21, 2022):

FYI: I'm starting to work on this feature for the MSFT hackathon. https://hackbox.microsoft.com/project/5766

@sotteson1 commented on GitHub (Sep 21, 2022): FYI: I'm starting to work on this feature for the MSFT hackathon. https://hackbox.microsoft.com/project/5766
Author
Owner

@NewtonChutney commented on GitHub (Sep 27, 2022):

FYI: I'm starting to work on this feature for the MSFT hackathon. https://hackbox.microsoft.com/project/5766

Oooohh! Thank you! 😃

@NewtonChutney commented on GitHub (Sep 27, 2022): > FYI: I'm starting to work on this feature for the MSFT hackathon. https://hackbox.microsoft.com/project/5766 Oooohh! Thank you! 😃
Author
Owner

@ghost commented on GitHub (Jan 24, 2023):

:tada:This issue was addressed in #14060, which has now been successfully released as Windows Terminal Preview v1.17.1023.🎉

Handy links:

@ghost commented on GitHub (Jan 24, 2023): :tada:This issue was addressed in #14060, which has now been successfully released as `Windows Terminal Preview v1.17.1023`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.17.1023) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17179