From 6cad4c35e90306715b311761aebccd63cfe944da Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 6 Apr 2022 17:53:46 -0700 Subject: [PATCH] Improve exit_behavior messaging some more --- mux/src/domain.rs | 10 ++++++++-- mux/src/localpane.rs | 6 +++--- pty/src/cmdbuilder.rs | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mux/src/domain.rs b/mux/src/domain.rs index 7d8268678..7214350d2 100644 --- a/mux/src/domain.rs +++ b/mux/src/domain.rs @@ -271,10 +271,16 @@ impl Domain for LocalDomain { let pane_id = alloc_pane_id(); cmd.env("WEZTERM_PANE", pane_id.to_string()); + let command_line = cmd + .as_unix_command_line() + .unwrap_or_else(|err| format!("error rendering command line: {:?}", err)); let command_description = format!( "\"{}\" in domain \"{}\"", - cmd.as_unix_command_line() - .unwrap_or_else(|err| format!("error rendering command line: {:?}", err)), + if command_line.is_empty() { + cmd.get_shell()? + } else { + command_line + }, self.name ); let child = pair.slave.spawn_command(cmd)?; diff --git a/mux/src/localpane.rs b/mux/src/localpane.rs index 1b182d6c2..f6a381c0b 100644 --- a/mux/src/localpane.rs +++ b/mux/src/localpane.rs @@ -164,7 +164,7 @@ impl Pane for LocalPane { (ExitBehavior::Close, _, _) => *proc = ProcessState::Dead, (ExitBehavior::CloseOnCleanExit, false, false) => { notify = Some(format!( - "\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"CloseOnCleanExit\"\r\n", + "\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"CloseOnCleanExit\"\r\n", self.command_description, EXIT_BEHAVIOR )); @@ -174,12 +174,12 @@ impl Pane for LocalPane { (ExitBehavior::Hold, success, false) => { if success { notify = Some(format!( - "\r\n👍Process {} completed.\r\n{}=\"Hold\"\r\n", + "\r\n👍 Process {} completed.\r\n{}=\"Hold\"\r\n", self.command_description, EXIT_BEHAVIOR )); } else { notify = Some(format!( - "\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"Hold\"\r\n", + "\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"Hold\"\r\n", self.command_description, EXIT_BEHAVIOR )); } diff --git a/pty/src/cmdbuilder.rs b/pty/src/cmdbuilder.rs index ebec17643..ed93a86b8 100644 --- a/pty/src/cmdbuilder.rs +++ b/pty/src/cmdbuilder.rs @@ -318,7 +318,7 @@ impl CommandBuilder { /// Determine which shell to run. /// We take the contents of the $SHELL env var first, then /// fall back to looking it up from the password database. - fn get_shell(&self) -> anyhow::Result { + pub fn get_shell(&self) -> anyhow::Result { if let Some(shell) = self.get_env("SHELL").and_then(OsStr::to_str) { return Ok(shell.into()); }