mirror of
https://github.com/anotherhadi/nixy.git
synced 2026-04-04 12:02:09 +02:00
from tmux to kitty
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> Former-commit-id: 049f6885e51fa8227f6cd7da2a4954387eb6f0d8
This commit is contained in:
@@ -3,11 +3,11 @@
|
|||||||
programs.kitty = {
|
programs.kitty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
keybindings = {
|
keybindings = {
|
||||||
"ctrl+shift+j" = "neighboring_window down";
|
|
||||||
"ctrl+shift+h" = "neighboring_window left";
|
|
||||||
"ctrl+shift+l" = "neighboring_window right";
|
|
||||||
"ctrl+shift+k" = "neighboring_window up";
|
|
||||||
"ctrl+shift+tab" = "new_tab";
|
"ctrl+shift+tab" = "new_tab";
|
||||||
|
"ctrl+j" = ''kitten pass_keys.py bottom ctrl+j'';
|
||||||
|
"ctrl+k" = ''kitten pass_keys.py top ctrl+k'';
|
||||||
|
"ctrl+h" = ''kitten pass_keys.py left ctrl+h'';
|
||||||
|
"ctrl+l" = ''kitten pass_keys.py right ctrl+l'';
|
||||||
};
|
};
|
||||||
settings = {
|
settings = {
|
||||||
scrollback_lines = 10000;
|
scrollback_lines = 10000;
|
||||||
@@ -26,6 +26,71 @@
|
|||||||
cursor_trail_decay = "0.1 0.4";
|
cursor_trail_decay = "0.1 0.4";
|
||||||
window_padding_width = 10;
|
window_padding_width = 10;
|
||||||
open_url_with = "default";
|
open_url_with = "default";
|
||||||
|
allow_remote_control = "yes";
|
||||||
|
listen_on = "unix:/tmp/mykitty";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xdg.configFile = {
|
||||||
|
"kitty/pass_keys.py".text = ''
|
||||||
|
import re
|
||||||
|
|
||||||
|
from kittens.tui.handler import result_handler
|
||||||
|
from kitty.key_encoding import KeyEvent, parse_shortcut
|
||||||
|
|
||||||
|
|
||||||
|
def is_window_vim(window, vim_id):
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def encode_key_mapping(window, key_mapping):
|
||||||
|
mods, key = parse_shortcut(key_mapping)
|
||||||
|
event = KeyEvent(
|
||||||
|
mods=mods,
|
||||||
|
key=key,
|
||||||
|
shift=bool(mods & 1),
|
||||||
|
alt=bool(mods & 2),
|
||||||
|
ctrl=bool(mods & 4),
|
||||||
|
super=bool(mods & 8),
|
||||||
|
hyper=bool(mods & 16),
|
||||||
|
meta=bool(mods & 32),
|
||||||
|
).as_window_system_event()
|
||||||
|
|
||||||
|
return window.encoded_key(event)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@result_handler(no_ui=True)
|
||||||
|
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)
|
||||||
|
|
||||||
|
if window is None:
|
||||||
|
return
|
||||||
|
if is_window_vim(window, vim_id):
|
||||||
|
for keymap in key_mapping.split(">"):
|
||||||
|
encoded = encode_key_mapping(window, keymap)
|
||||||
|
window.write_to_child(encoded)
|
||||||
|
else:
|
||||||
|
boss.active_tab.neighboring_window(direction)
|
||||||
|
'';
|
||||||
|
"kitty/neighboring_window.py".text = ''
|
||||||
|
def main():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def handle_result(args, result, target_window_id, boss):
|
||||||
|
return boss.active_tab.current_layout.name
|
||||||
|
|
||||||
|
|
||||||
|
handle_result.no_ui = True
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user