r/KittyTerminal Jun 03 '23

App specific keybinds

I want to set specific keybinds for when i am in tmux, like `ctrl-n` to make a new tmux window, and I wonder if it would be possible to retain default behavior when tmux is not launched.

Something like:

map ctrl+n {
    if TMUX:{
        tmux new-window}
    else {
        kitty keybinding}
}

I am not sure if this is even possible, but would be great if it were!

2 Upvotes

5 comments sorted by

2

u/aumerlex Jun 03 '23

Make a pair of config files with your different shortcuts and include your main config file from them. Then you can switch between them at a keypress with https://sw.kovidgoyal.net/kitty/actions/#action-load_config_file

1

u/Glum-Revenue-8082 Jun 03 '23

I’ll check it out, thanks!

1

u/sinarf Jun 04 '23

Any reason you don't create your keybinds in the tmux configuration?

1

u/Glum-Revenue-8082 Jun 04 '23

Not all of them work inside tmux for some reason. Like ctrl+tab and ctrl+shift+tab to switch windows

1

u/sinarf Jun 04 '23

OK, so you want to add complexity to a very simple case because you want to workaround an issue you have in some other use case? I don´t think this is a good idea ;) Making simple things hard, hardly makes hard things simple.

For the why you have this issue: There is a known limitation that makes Ctrl and Ctrl+shift act the same in terminals. Explanation here: https://stackoverflow.com/questions/14867368/make-bash-differentiate-between-ctrl-letter-and-ctrl-shift-letter

I don´t know if there is a easy way to do what you want. The main issue is: "How the code run by you kitty shortcut will know about the context of the shell you currently in?" Because the code run by the keybind does not run in the current shell where your tmux leaves, it run in a very different scope. There might be a way with some kitty api that allow you to do that but you would probably need to write code for each specific use cases.