diff --git a/src/input_common.rs b/src/input_common.rs index 6a0bfeb34..a65267055 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -437,6 +437,7 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) { pub(crate) static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub(crate) static IN_MIDNIGHT_COMMANDER: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub(crate) static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +pub(crate) static IN_WEZTERM: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocols_enable_ifn() { if IN_MIDNIGHT_COMMANDER.load() { @@ -463,7 +464,9 @@ struct TerminalProtocols {} impl TerminalProtocols { fn new() -> Self { - let sequences = if IN_ITERM_PRE_CSI_U.load() { + let sequences = if IN_WEZTERM.load() { + "\x1b[?2004h" + } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b[>5u", "\x1b=",) } else { concat!( @@ -491,7 +494,9 @@ fn new() -> Self { impl Drop for TerminalProtocols { fn drop(&mut self) { - let sequences = if IN_ITERM_PRE_CSI_U.load() { + let sequences = if IN_WEZTERM.load() { + "\x1b[?2004l" + } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",) } else { concat!( diff --git a/src/reader.rs b/src/reader.rs index 8368ba443..8a5371602 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -72,6 +72,7 @@ use crate::input::init_input; use crate::input_common::IN_ITERM_PRE_CSI_U; use crate::input_common::IN_MIDNIGHT_COMMANDER; +use crate::input_common::IN_WEZTERM; use crate::input_common::{ terminal_protocols_disable_ifn, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData, ReadlineCmd, IS_TMUX, @@ -3857,6 +3858,12 @@ fn reader_interactive_init(parser: &Parser) { fn interactive_hacks(parser: &Parser) { IS_TMUX.store(parser.vars().get_unless_empty(L!("TMUX")).is_some()); IN_MIDNIGHT_COMMANDER.store(parser.vars().get_unless_empty(L!("MC_TMPDIR")).is_some()); + IN_WEZTERM.store( + parser + .vars() + .get_unless_empty(L!("TERM_PROGRAM")) + .is_some_and(|term_program| term_program.as_list() == [L!("WezTerm")]), + ); IN_ITERM_PRE_CSI_U.store( parser .vars()