From 4378e73fc746b539c851c22800b42fdfeb1a1964 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 3 Mar 2025 10:37:49 +0100 Subject: [PATCH] Add the commandline to the OSC 133 command start Given $ cat ~/.config/kitty/kitty.conf notify_on_cmd_finish unfocused 0.1 command notify-send "job finished with status: %s" %c kitty will send a notification whenever a long-running (>.1s) foreground command finishes while kitty is not focused. The %c placeholder will be replaced by the commandline. This is passed via the OSC 133 command start marker, kitty's fish shell integration. That integration has been disabled for fish 4.0.0 because it's no longer necessary since fish already prints OSC 133. But we missed the parameter for the command string. Fix it. (It's debatable whether the shell or the terminal should provide this feature but I think we should fix this regression?) Closes #11203 See https://github.com/kovidgoyal/kitty/issues/8385#issuecomment-2692659161 --- src/reader.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index 16384174f..f54e4ee60 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -105,6 +105,7 @@ use crate::operation_context::{get_bg_context, OperationContext}; use crate::output::parse_color; use crate::output::parse_color_maybe_none; +use crate::output::BufferedOuputter; use crate::output::Outputter; use crate::pager::{PageRendering, Pager, SelectionMotion}; use crate::panic::AT_EXIT; @@ -690,8 +691,13 @@ fn read_i(parser: &Parser) -> i32 { data.clear(EditableLineTag::Commandline); data.update_buff_pos(EditableLineTag::Commandline, None); - // OSC 133 End of command - data.screen.write_bytes(b"\x1b]133;C\x07"); + // OSC 133 "Command start" + write!( + BufferedOuputter::new(&mut Outputter::stdoutput().borrow_mut()), + "\x1b]133;C;cmdline_url={}\x07", + escape_string(&command, EscapeStringStyle::Url), + ) + .unwrap(); event::fire_generic(parser, L!("fish_preexec").to_owned(), vec![command.clone()]); let eval_res = reader_run_command(parser, &command); signal_clear_cancel();