Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mux): Use tmux inside kitty and compatible with window shortcuts #208

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Conversation

mochouaaaaa
Copy link
Contributor

kitty.conf
The shortcut here is passed to tmux

map cmd+j kitten neighboring_window.py bottom cmd+j
map cmd+k kitten neighboring_window.py top    cmd+k
map cmd+h kitten neighboring_window.py left   cmd+h
map cmd+l kitten neighboring_window.py right  cmd+l

map --when-focus-on var:IS_NVIM cmd+j
map --when-focus-on var:IS_NVIM cmd+k
map --when-focus-on var:IS_NVIM cmd+h
map --when-focus-on var:IS_NVIM cmd+l

map ctrl+shift+j kitten relative_resize.py down  3 ctrl+shift+j 
map ctrl+shift+k kitten relative_resize.py up    3 ctrl+shift+k
map ctrl+shift+h kitten relative_resize.py left  3 ctrl+shift+h
map ctrl+shift+l kitten relative_resize.py right 3 ctrl+shift+l

map --when-focus-on var:IS_NVIM ctrl+shift+j
map --when-focus-on var:IS_NVIM ctrl+shift+k
map --when-focus-on var:IS_NVIM ctrl+shift+h
map --when-focus-on var:IS_NVIM ctrl+shift+l

map cmd+ctrl+j kitten split_window.py down    cmd+ctrl+j
map cmd+ctrl+k kitten split_window.py up      cmd+ctrl+k
map cmd+ctrl+h kitten split_window.py left    cmd+ctrl+h
map cmd+ctrl+l kitten split_window.py right   cmd+ctrl+l

tmux.conf

bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h'  'select-pane -L'
bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j'  'select-pane -D'
bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k'  'select-pane -U'
bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l'  'select-pane -R'

bind-key -n C-S-h if -F "#{@pane-is-vim}" 'send-keys C-S-h' 'resize-pane -L 3'
bind-key -n C-S-j if -F "#{@pane-is-vim}" 'send-keys C-S-j' 'resize-pane -D 3'
bind-key -n C-S-k if -F "#{@pane-is-vim}" 'send-keys C-S-k' 'resize-pane -U 3'
bind-key -n C-S-l if -F "#{@pane-is-vim}" 'send-keys C-S-l' 'resize-pane -R 3'

bind-key -n C-M-k if -F "#{@pane-is-vim}" 'send-keys C-M-k' 'split-window -v -c "#{pane_current_path}"'
bind-key -n C-M-j if -F "#{@pane-is-vim}" 'send-keys C-M-j' 'split-window -v -c "#{pane_current_path}"'
bind-key -n C-M-l if -F "#{@pane-is-vim}" 'send-keys C-M-l' 'split-window -h -c "#{pane_current_path}"'
bind-key -n C-M-h if -F "#{@pane-is-vim}" 'send-keys C-M-h' 'split-window -h -c "#{pane_current_path}"'

neovim
On mac systems, the cmd key cannot be used with ‘D’ but rather ‘M’, because tmux sends over the M

vim.keymap.set("n", "<C-S-k>", function()
    smart_splits.resize_up()
end)
vim.keymap.set("n", "<C-S-j>", function()
    smart_splits.resize_down()
end)
vim.keymap.set("n", "<C-S-h>", function()
    smart_splits.resize_left()
end)
vim.keymap.set("n", "<C-S-l>", function()
    smart_splits.resize_right()
end)

vim.keymap.set("n",  "<M-k>", function()
    smart_splits.move_cursor_up()
end)
vim.keymap.set("n", "<M-j>", function()
    smart_splits.move_cursor_down()
end)
vim.keymap.set("n", "<M-h>", function()
    smart_splits.move_cursor_left()
end)
vim.keymap.set("n","<M-l>", function()
    smart_splits.move_cursor_right()
end)

local mux = require("smart-splits.mux").get()
vim.keymap.set("n","<M-C-k>", function()
    mux.split_pane("up")
end)
vim.keymap.set("n", "<M-C-j>", function()
    mux.split_pane("down")
end)
vim.keymap.set("n", "<M-C-h>", function()
    mux.split_pane("left")
end)
vim.keymap.set("n", "<M-C-l>", function()
    mux.split_pane("right")
end)

kitty_tmux_move
kitty_tmux_resize

@mochouaaaaa mochouaaaaa changed the title feature(mux): Use tmux inside kitty and compatible with window shortcuts feat(mux): Use tmux inside kitty and compatible with window shortcuts Jun 5, 2024
@mrjones2014
Copy link
Owner

Can you explain a little more about what these changes are doing, why they're needed, and whether they'll interfere with people just using Kitty's mux and not using tmux?

@mochouaaaaa
Copy link
Contributor Author

It does not interfere with any way of use
There is no effect when using only kitty, as no code has been changed.
In the use of tmux and kiity just one more operation, that is, the shortcut key send to tmux, when using tmux, at this time the shortcut key operation will call tmux's window operation instead of kitty's.

@mrjones2014 mrjones2014 merged commit 66fda3a into mrjones2014:master Jun 5, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants