Improve exit_behavior messaging
refs: https://github.com/wez/wezterm/issues/1791#issuecomment-1090059541
This commit is contained in:
1 parent
a1b573c3c5
commit
1908d35d03
4 files changed
+29
-9
No files matched your search
@@ -271,6 +271,12 @@ impl Domain for LocalDomain {
|
||||
let pane_id = alloc_pane_id();
|
||||
cmd.env("WEZTERM_PANE", pane_id.to_string());
|
||||
|
||||
let command_description = format!(
|
||||
"\"{}\" in domain \"{}\"",
|
||||
cmd.as_unix_command_line()
|
||||
.unwrap_or_else(|err| format!("error rendering command line: {:?}", err)),
|
||||
self.name
|
||||
);
|
||||
let child = pair.slave.spawn_command(cmd)?;
|
||||
log::trace!("spawned: {:?}", child);
|
||||
|
||||
@@ -293,6 +299,7 @@ impl Domain for LocalDomain {
|
||||
child,
|
||||
pair.master,
|
||||
self.id,
|
||||
command_description,
|
||||
));
|
||||
|
||||
let mux = Mux::get().unwrap();
|
||||
|
||||
+13
-8
@@ -56,6 +56,7 @@ pub struct LocalPane {
|
||||
domain_id: DomainId,
|
||||
tmux_domain: RefCell<Option<Arc<TmuxDomainState>>>,
|
||||
proc_list: RefCell<Option<CachedProcInfo>>,
|
||||
command_description: String,
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
@@ -142,9 +143,10 @@ impl Pane for LocalPane {
|
||||
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\\";
|
||||
const EXIT_BEHAVIOR: &str = "This message is shown because \
|
||||
\x1b]8;;https://wezfurlong.org/wezterm/\
|
||||
config/lua/config/exit_behavior.html\
|
||||
\x1b\\exit_behavior\x1b]8;;\x1b\\";
|
||||
|
||||
match &mut *proc {
|
||||
ProcessState::Running {
|
||||
@@ -162,7 +164,8 @@ impl Pane for LocalPane {
|
||||
(ExitBehavior::Close, _, _) => *proc = ProcessState::Dead,
|
||||
(ExitBehavior::CloseOnCleanExit, false, false) => {
|
||||
notify = Some(format!(
|
||||
"\r\n[Process didn't exit cleanly. ({}=\"CloseOnCleanExit\")]\r\n",
|
||||
"\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"CloseOnCleanExit\"\r\n",
|
||||
self.command_description,
|
||||
EXIT_BEHAVIOR
|
||||
));
|
||||
*proc = ProcessState::DeadPendingClose { killed: false }
|
||||
@@ -171,13 +174,13 @@ impl Pane for LocalPane {
|
||||
(ExitBehavior::Hold, success, false) => {
|
||||
if success {
|
||||
notify = Some(format!(
|
||||
"\r\n[Process completed. ({}=\"Hold\")]\r\n",
|
||||
EXIT_BEHAVIOR
|
||||
"\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. ({}=\"Hold\")]\r\n",
|
||||
EXIT_BEHAVIOR
|
||||
"\r\n⚠️ Process {} didn't exit cleanly.\r\n{}=\"Hold\"\r\n",
|
||||
self.command_description, EXIT_BEHAVIOR
|
||||
));
|
||||
}
|
||||
*proc = ProcessState::DeadPendingClose { killed: false }
|
||||
@@ -732,6 +735,7 @@ impl LocalPane {
|
||||
process: Box<dyn Child + Send>,
|
||||
pty: Box<dyn MasterPty>,
|
||||
domain_id: DomainId,
|
||||
command_description: String,
|
||||
) -> Self {
|
||||
let (process, signaller, pid) = split_child(process);
|
||||
|
||||
@@ -753,6 +757,7 @@ impl LocalPane {
|
||||
domain_id,
|
||||
tmux_domain: RefCell::new(None),
|
||||
proc_list: RefCell::new(None),
|
||||
command_description,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -656,7 +656,14 @@ impl Domain for RemoteSshDomain {
|
||||
writer,
|
||||
);
|
||||
|
||||
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(pane_id, terminal, child, pty, self.id));
|
||||
let pane: Rc<dyn Pane> = Rc::new(LocalPane::new(
|
||||
pane_id,
|
||||
terminal,
|
||||
child,
|
||||
pty,
|
||||
self.id,
|
||||
"RemoteSshDomain".to_string(),
|
||||
));
|
||||
let mux = Mux::get().unwrap();
|
||||
mux.add_pane(&pane)?;
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ impl TmuxDomainState {
|
||||
Box::new(child),
|
||||
Box::new(pane_pty),
|
||||
self.domain_id,
|
||||
"tmux pane".to_string(),
|
||||
));
|
||||
|
||||
let tab = Rc::new(Tab::new(&size));
|
||||
|
||||
Reference in new issue
Block a user