🎹 Keymap update
- Remove Ctrl+Shift+h map for scrollback - Map kittyscrollback to F1 - Replace instances of Ctrl+Shift with kitty_mod - Switch to MunsMan/kitty-navigator.nvim - Ctrl+Shift+<vim-motions> hard-coded for switching windows - Mappings now properly integrate with nvim
This commit is contained in:
+19
-25
@@ -34,21 +34,21 @@ map f2 remove_marker
|
|||||||
map f3 toggle_marker itext 2 ERROR 1 WARNING 3 PASS
|
map f3 toggle_marker itext 2 ERROR 1 WARNING 3 PASS
|
||||||
map f12 load_config_file /home/rootiest/.config/kitty/kitty.conf
|
map f12 load_config_file /home/rootiest/.config/kitty/kitty.conf
|
||||||
|
|
||||||
map ctrl+shift+c copy_to_clipboard
|
map kitty_mod+c copy_to_clipboard
|
||||||
map ctrl+shift+v paste_from_clipboard
|
map kitty_mod+v paste_from_clipboard
|
||||||
map ctrl+shift+s paste_from_selection
|
map kitty_mod+s paste_from_selection
|
||||||
map shift+insert paste_from_selection
|
map shift+insert paste_from_selection
|
||||||
map ctrl+shift+o pass_selection_to_program
|
map kitty_mod+o pass_selection_to_program
|
||||||
|
|
||||||
map ctrl+shift+right next_tab
|
map kitty_mod+right next_tab
|
||||||
map ctrl+tab next_tab
|
map ctrl+tab next_tab
|
||||||
map ctrl+shift+right next_tab
|
map kitty_mod+right next_tab
|
||||||
map ctrl+tab next_tab
|
map ctrl+tab next_tab
|
||||||
map ctrl+shift+q close_tab
|
map kitty_mod+q close_tab
|
||||||
|
|
||||||
# View the scrollback buffer
|
# View the scrollback buffer
|
||||||
map ctrl+shift+b view_scrollback
|
#map kitty_mod+b view_scrollback
|
||||||
map f1 view_scrollback
|
map f1 kitty_scrollback_nvim
|
||||||
|
|
||||||
# Create a new window splitting the space used by the existing one so that
|
# Create a new window splitting the space used by the existing one so that
|
||||||
# the two windows are placed one above the other
|
# the two windows are placed one above the other
|
||||||
@@ -60,7 +60,7 @@ map f6 launch --location=vsplit
|
|||||||
|
|
||||||
# Create a new window splitting the space used by the existing one so that
|
# Create a new window splitting the space used by the existing one so that
|
||||||
# the two windows are placed side by side if the existing window is wide or
|
# the two windows are placed side by side if the existing window is wide or
|
||||||
# one above the other if the existing window is tall.
|
one above the other if the existing window is tall.
|
||||||
map f4 launch --location=split
|
map f4 launch --location=split
|
||||||
|
|
||||||
# Rotate the current split, changing its split axis from vertical to
|
# Rotate the current split, changing its split axis from vertical to
|
||||||
@@ -69,7 +69,7 @@ map f7 layout_action rotate
|
|||||||
|
|
||||||
# Open nvim in a new tab
|
# Open nvim in a new tab
|
||||||
map f8 launch_tab nvim
|
map f8 launch_tab nvim
|
||||||
map ctrl+shift+n launch_tab nvim
|
map kitty_mod+n launch_tab nvim
|
||||||
|
|
||||||
|
|
||||||
# Move the active window in the indicated direction
|
# Move the active window in the indicated direction
|
||||||
@@ -78,12 +78,6 @@ map shift+left move_window left
|
|||||||
map shift+right move_window right
|
map shift+right move_window right
|
||||||
map shift+down move_window down
|
map shift+down move_window down
|
||||||
|
|
||||||
# Move the active window to the indicated screen edge
|
|
||||||
map ctrl+shift+up layout_action move_to_screen_edge top
|
|
||||||
map ctrl+shift+left layout_action move_to_screen_edge left
|
|
||||||
map ctrl+shift+right layout_action move_to_screen_edge right
|
|
||||||
map ctrl+shift+down layout_action move_to_screen_edge bottom
|
|
||||||
|
|
||||||
# Switch focus to the neighboring window in the indicated direction
|
# Switch focus to the neighboring window in the indicated direction
|
||||||
map alt+left neighboring_window left
|
map alt+left neighboring_window left
|
||||||
map alt+right neighboring_window right
|
map alt+right neighboring_window right
|
||||||
@@ -92,21 +86,21 @@ map alt+down neighboring_window down
|
|||||||
|
|
||||||
### Kittens ###
|
### Kittens ###
|
||||||
#kitty-search
|
#kitty-search
|
||||||
map ctrl+shift+q launch --allow-remote-control kitty +kitten kitty_search/search.py @active-kitty-window-id
|
map kitty_mod+q launch --allow-remote-control kitty +kitten kitty_search/search.py @active-kitty-window-id
|
||||||
|
|
||||||
### NVim Plugins
|
### NVim Plugins
|
||||||
map ctrl+j kitten pass_keys.py bottom ctrl+j
|
map ctrl+shift+j kitten pass_keys.py neighboring_window bottom ctrl+shift+j
|
||||||
map ctrl+k kitten pass_keys.py top ctrl+k
|
map ctrl+shift+k kitten pass_keys.py neighboring_window top ctrl+shift+k
|
||||||
map ctrl+h kitten pass_keys.py left ctrl+h
|
map ctrl+shift+h kitten pass_keys.py neighboring_window left ctrl+shift+h
|
||||||
map ctrl+l kitten pass_keys.py right ctrl+l
|
map ctrl+shift+l kitten pass_keys.py neighboring_window right ctrl+shift+l
|
||||||
|
|
||||||
## NVim Kitty Scrollback
|
## NVim Kitty Scrollback
|
||||||
# Browse scrollback buffer in nvim
|
# Browse scrollback buffer in nvim
|
||||||
#map kitty_mod+h kitty_scrollback_nvim --nvim-args --clean --noplugin -n
|
#map kitty_mod+h kitty_scrollback_nvim --nvim-args --clean --noplugin -n
|
||||||
map kitty_mod+h kitty_scrollback_nvim
|
#map kitty_mod+b kitty_scrollback_nvim
|
||||||
# Browse output of the last shell command in nvim
|
# Browse output of the last shell command in nvim
|
||||||
#map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output --nvim-args --clean --noplugin -n
|
#map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output --nvim-args --clean --noplugin -n
|
||||||
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
|
map kitty_mod+b kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
|
||||||
# Show clicked command output in nvim
|
# Show clicked command output in nvim
|
||||||
mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
|
mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from kittens.tui.handler import result_handler
|
||||||
|
from typing import List
|
||||||
|
from kitty.boss import Boss
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
directions = ["right", "left", "top", "bottom"]
|
||||||
|
|
||||||
|
|
||||||
|
@result_handler(no_ui=True)
|
||||||
|
def handle_result(args: List[str], result: str, target_window_id: int, boss: Boss):
|
||||||
|
if len(args) == 2 and args[1] in directions:
|
||||||
|
boss.active_tab.neighboring_window(args[1])
|
||||||
+10
-7
@@ -3,10 +3,15 @@ import re
|
|||||||
from kittens.tui.handler import result_handler
|
from kittens.tui.handler import result_handler
|
||||||
from kitty.key_encoding import KeyEvent, parse_shortcut
|
from kitty.key_encoding import KeyEvent, parse_shortcut
|
||||||
|
|
||||||
|
VIM_ID = "n?vim"
|
||||||
|
|
||||||
def is_window_vim(window, vim_id):
|
|
||||||
|
def is_window_vim(window):
|
||||||
fp = window.child.foreground_processes
|
fp = window.child.foreground_processes
|
||||||
return any(re.search(vim_id, p['cmdline'][0] if len(p['cmdline']) else '', re.I) for p in fp)
|
return any(
|
||||||
|
re.search(VIM_ID, p["cmdline"][0] if len(p["cmdline"]) else "", re.I)
|
||||||
|
for p in fp
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def encode_key_mapping(window, key_mapping):
|
def encode_key_mapping(window, key_mapping):
|
||||||
@@ -31,15 +36,13 @@ def main():
|
|||||||
|
|
||||||
@result_handler(no_ui=True)
|
@result_handler(no_ui=True)
|
||||||
def handle_result(args, result, target_window_id, boss):
|
def handle_result(args, result, target_window_id, boss):
|
||||||
direction = args[1]
|
|
||||||
key_mapping = args[2]
|
|
||||||
vim_id = args[3] if len(args) > 3 else "n?vim"
|
|
||||||
|
|
||||||
window = boss.window_id_map.get(target_window_id)
|
window = boss.window_id_map.get(target_window_id)
|
||||||
|
direction = args[2]
|
||||||
|
key_mapping = args[3]
|
||||||
|
|
||||||
if window is None:
|
if window is None:
|
||||||
return
|
return
|
||||||
if is_window_vim(window, vim_id):
|
if is_window_vim(window):
|
||||||
for keymap in key_mapping.split(">"):
|
for keymap in key_mapping.split(">"):
|
||||||
encoded = encode_key_mapping(window, keymap)
|
encoded = encode_key_mapping(window, keymap)
|
||||||
window.write_to_child(encoded)
|
window.write_to_child(encoded)
|
||||||
|
|||||||
Reference in New Issue
Block a user