kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
21.98k stars 899 forks source link

Allow `combine` mappable action to use a custom delimiter #7281

Closed salmankhilji closed 1 month ago

salmankhilji commented 1 month ago

Describe the bug The combine mappable action does not support actions that themselves use a : within their arguments.

For example, the following mappings do not work:

map f1 combine : toggle_tab index:0 : send_text normal foo
map f1 combine : remote_control !focus-window --match title:foo : send_text normal foo

To Reproduce Steps to reproduce the behavior:

  1. Launch kitty like this:

    kitty --config NONE -o "map f1 combine : goto_tab 0 : send_text normal foo"
  2. Create a new tab using kitty_mod+t.

  3. Verify that pressing F1 switches to the first tab and the text foo appears within the window.

  4. Now relaunch kitty like this:

    kitty --config NONE -o "map f1 combine : toggle_tab index:0 : send_text normal foo"
  5. Press F1.

Observed error

Screenshot from 2024-03-28 22-04-28

Environment details

kitty 0.33.1 (a5fea33757) created by Kovid Goyal
Linux byteevo 5.15.0-101-generic #111~20.04.1-Ubuntu SMP Mon Mar 11 15:44:43 UTC 2024 x86_64
Ubuntu 20.04.6 LTS byteevo /dev/tty

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
Running under: X11
Frozen: True
Paths:
  kitty: /home/precor/.local/kitty.app/bin/kitty
  base dir: /home/precor/.local/kitty.app/lib/kitty
  extensions dir: /home/precor/.local/kitty.app/lib/kitty-extensions
  system shell: /bin/bash
Loaded config overrides:
  map f1 combine : toggle_tab index:0 : send_text normal foo

Config options different from defaults:
Added shortcuts:
    f1 →  combine : toggle_tab index:0 : send_text normal foo

Important environment variables seen by the kitty process:
    PATH                                /home/precor/.local/lib/precor:/home/precor/.local/bin:/home/precor/.local/node/bin:/opt/qt/5.15.2/gcc_64/bin:/home/precor/Android/Sdk/build-tools/34.0.0:/home/precor/Android/Sdk/emulator:/home/precor/Android/Sdk/platform-tools:/home/precor/Android/Sdk/cmdline-tools/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    LANG                                en_US.UTF-8
    SHELL                               /bin/bash
    DISPLAY                             :0
    USER                                precor
    XDG_CONFIG_DIRS                     /etc/xdg/xdg-ubuntu:/etc/xdg
    XDG_MENU_PREFIX                     gnome-
    XDG_SESSION_DESKTOP                 ubuntu
    XDG_SESSION_TYPE                    x11
    XDG_CURRENT_DESKTOP                 ubuntu:GNOME
    XDG_SESSION_CLASS                   user
    XDG_RUNTIME_DIR                     /run/user/1000
    XDG_DATA_DIRS                       /usr/share/ubuntu:/usr/local/share/:/usr/share/

Suggested Fix Perhaps we can allow combine to take an arbitrary delimiter, similar to sed. The solution might look like this:

map f1 combine / toggle_tab index:0 / send_text normal foo
map f1 combine % remote_control !focus-window --match title:foo % send_text normal foo
kovidgoyal commented 1 month ago

Sure it does: https://sw.kovidgoyal.net/kitty/actions/#action-combine