diff --git a/kitty/rc/set_tab_title.py b/kitty/rc/set_tab_title.py index 82ff2eda0..969cd711d 100644 --- a/kitty/rc/set_tab_title.py +++ b/kitty/rc/set_tab_title.py @@ -28,7 +28,7 @@ class SetTabTitle(RemoteCommand): ' title of the currently active window in the tab is used.' ) options_spec = MATCH_TAB_OPTION - args = RemoteCommand.Args(spec='TITLE ...', json_field='title') + args = RemoteCommand.Args(spec='TITLE ...', json_field='title', special_parse='expand_ansi_c_escapes_in_args(args...)') def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: return {'title': ' '.join(args), 'match': opts.match} diff --git a/kitty/rc/set_window_title.py b/kitty/rc/set_window_title.py index 09f17adb9..4e319ad78 100644 --- a/kitty/rc/set_window_title.py +++ b/kitty/rc/set_window_title.py @@ -33,7 +33,7 @@ type=bool-set By default, the title will be permanently changed and programs running in the window will not be able to change it again. If you want to allow other programs to change it afterwards, use this option. ''' + '\n\n' + MATCH_WINDOW_OPTION - args = RemoteCommand.Args(json_field='title', spec='[TITLE ...]') + args = RemoteCommand.Args(json_field='title', spec='[TITLE ...]', special_parse='expand_ansi_c_escapes_in_args(args...)') def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: ans = {'match': opts.match, 'temporary': opts.temporary} diff --git a/tools/cmd/at/main.go b/tools/cmd/at/main.go index 9dae9b60d..85ff36a4a 100644 --- a/tools/cmd/at/main.go +++ b/tools/cmd/at/main.go @@ -22,6 +22,7 @@ import ( "kitty/tools/tui" "kitty/tools/tui/loop" "kitty/tools/utils" + "kitty/tools/utils/shlex" "github.com/jamesruan/go-rfc1924/base85" ) @@ -35,6 +36,13 @@ type GlobalOptions struct { var global_options GlobalOptions +func expand_ansi_c_escapes_in_args(args ...string) (string, error) { + for i, x := range args { + args[i] = shlex.ExpandANSICEscapes(x) + } + return strings.Join(args, " "), nil +} + func set_payload_string_field(io_data *rc_io_data, field, data string) { payload_interface := reflect.ValueOf(&io_data.rc.Payload).Elem() struct_in_interface := reflect.New(payload_interface.Elem().Type()).Elem()