1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 22:42:48 +03:00

improve exit_behavior messaging

The status information now explains the exit status and the
exit_behavior, as well as links to the docs on exit_behavior.

refs: https://github.com/wez/wezterm/issues/795
This commit is contained in:
Wez Furlong 2021-05-15 08:32:29 -07:00
parent 69561b96c8
commit db45238769
4 changed files with 43 additions and 2 deletions

View File

@ -20,6 +20,7 @@ As features stabilize some brief notes about them will accumulate here.
* Fixed: incorrect Sixel HLS hue handling [#775](https://github.com/wez/wezterm/issues/775)
* Fixed: we now recognize the `CSI 48:2:0:214:255m` form of specifying true color text attributes [#785](https://github.com/wez/wezterm/issues/785)
* Fixed: split separators didn't respect `tab_bar_at_bottom=true` and were rendered in the wrong place [#797](https://github.com/wez/wezterm/issues/797)
* Improved: messaging around [exit_behavior](https://wezfurlong.org/wezterm/config/lua/config/exit_behavior.html)
### 20210502-154244-3f7122cb

View File

@ -14,3 +14,9 @@ return {
exit_behavior = "Hold",
}
```
Note that most unix shells will exit with the status of the last command that
it ran. If you interrupt a command and then use CTRL-D to send EOF to the
shell, the shell will return an unsuccessful exit status. With the default
`exit_behavior="CloseOnCleanExit"`, that will cause the pane to remain open.

View File

@ -185,7 +185,6 @@ fn read_from_pane_pty(pane_id: PaneId, banner: Option<String>, mut reader: Box<d
ExitBehavior::Hold | ExitBehavior::CloseOnCleanExit => {
// We don't know if we can unilaterally close
// this pane right now, so don't!
state.write(b"\n[Process completed]");
promise::spawn::spawn_into_main_thread(async move {
let mux = Mux::get().unwrap();
mux.prune_dead_windows();

View File

@ -111,6 +111,11 @@ impl Pane for LocalPane {
fn is_dead(&self) -> bool {
let mut proc = self.process.borrow_mut();
let mut notify = None;
const EXIT_BEHAVIOR: &str = "\x1b]8;;https://wezfurlong.org/wezterm/\
config/lua/config/exit_behavior.html\
\x1b\\exit_behavior\x1b]8;;\x1b\\";
match &mut *proc {
ProcessState::Running { child, killed } => {
@ -118,10 +123,25 @@ impl Pane for LocalPane {
match (configuration().exit_behavior, status.success(), killed) {
(ExitBehavior::Close, _, _) => *proc = ProcessState::Dead,
(ExitBehavior::CloseOnCleanExit, false, false) => {
notify = Some(format!(
"\r\n[Process didn't exit cleanly. ({}=\"CloseOnCleanExit\")]",
EXIT_BEHAVIOR
));
*proc = ProcessState::DeadPendingClose { killed: false }
}
(ExitBehavior::CloseOnCleanExit, ..) => *proc = ProcessState::Dead,
(ExitBehavior::Hold, _, false) => {
(ExitBehavior::Hold, success, false) => {
if success {
notify = Some(format!(
"\r\n[Process completed. ({}=\"Hold\")]",
EXIT_BEHAVIOR
));
} else {
notify = Some(format!(
"\r\n[Process didn't exit cleanly. ({}=\"Hold\")]",
EXIT_BEHAVIOR
));
}
*proc = ProcessState::DeadPendingClose { killed: false }
}
(ExitBehavior::Hold, _, true) => *proc = ProcessState::Dead,
@ -138,6 +158,21 @@ impl Pane for LocalPane {
ProcessState::Dead => {}
}
if let Some(notify) = notify {
let pane_id = self.pane_id;
promise::spawn::spawn_into_main_thread(async move {
let mux = Mux::get().unwrap();
if let Some(pane) = mux.get_pane(pane_id) {
let mut parser = termwiz::escape::parser::Parser::new();
let mut actions = vec![];
parser.parse(notify.as_bytes(), |action| actions.push(action));
pane.perform_actions(actions);
mux.notify(MuxNotification::PaneOutput(pane_id));
}
})
.detach();
}
match &*proc {
ProcessState::Running { .. } => false,
ProcessState::DeadPendingClose { .. } => false,