summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-06 18:34:18 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-06 19:00:59 +0100
commit530f2452d980a0ab6fafeb994bda5cfd1343df16 (patch)
tree0d7f0263cbf63e40a3749cc2bb50bef4651b8d0d /modules
parentscripts/build.sh: Don't fail if the result symlinks don't exist (diff)
downloadnixos-config-530f2452d980a0ab6fafeb994bda5cfd1343df16.zip
modules/fish: Make the defined keybindings actually work
From local testing, these now seem to be (more or less) the same as we had before.
Diffstat (limited to 'modules')
-rw-r--r--modules/by-name/fi/fish/keymappings.nix645
-rw-r--r--modules/by-name/fi/fish/module.nix36
2 files changed, 323 insertions, 358 deletions
diff --git a/modules/by-name/fi/fish/keymappings.nix b/modules/by-name/fi/fish/keymappings.nix
index 187c5d5a..cb4064c6 100644
--- a/modules/by-name/fi/fish/keymappings.nix
+++ b/modules/by-name/fi/fish/keymappings.nix
@@ -1,11 +1,12 @@
{lib, ...}:
lib.fix (self: let
fromInsert = key: self.insert."${key}".cmd;
+
+ escPlus = key: ''\e\[${key}'';
in {
"operator" = {
"escape" = {
cmd = "fish_vi_operator_cancel";
- sets_mode_to = "default";
};
"F" = {
cmd = "";
@@ -13,71 +14,54 @@ in {
};
"d" = {
cmd = "fish_vi_exec_motion --linewise";
- sets_mode_to = "default";
};
"e" = {
cmd = "fish_vi_exec_motion forward-word-end";
- sets_mode_to = "default";
};
"j" = {
cmd = "fish_vi_exec_motion down-line";
- sets_mode_to = "default";
};
"k" = {
cmd = "fish_vi_exec_motion up-line";
- sets_mode_to = "default";
};
"7" = {
cmd = "fish_vi_arg_digit 7";
- sets_mode_to = "default";
};
"h" = {
cmd = "fish_vi_exec_motion backward-char";
- sets_mode_to = "default";
};
"B" = {
cmd = "fish_vi_exec_motion backward-bigword";
- sets_mode_to = "default";
};
"9" = {
cmd = "fish_vi_arg_digit 9";
- sets_mode_to = "default";
};
"5" = {
cmd = "fish_vi_arg_digit 5";
- sets_mode_to = "default";
};
"E" = {
cmd = "fish_vi_exec_motion forward-bigword-end";
- sets_mode_to = "default";
};
"~" = {
cmd = "fish_vi_exec_motion --linewise";
- sets_mode_to = "default";
};
"4" = {
cmd = "fish_vi_arg_digit 4";
- sets_mode_to = "default";
};
"comma" = {
cmd = "fish_vi_exec_motion repeat-jump-reverse";
- sets_mode_to = "default";
};
"^" = {
cmd = "fish_vi_exec_motion beginning-of-line";
- sets_mode_to = "default";
};
- "ctrl-[" = {
+ "ctrl-\\[" = {
cmd = "fish_vi_operator_cancel";
- sets_mode_to = "default";
};
";" = {
cmd = "fish_vi_exec_motion repeat-jump";
- sets_mode_to = "default";
};
"c" = {
cmd = "fish_vi_exec_motion --linewise";
- sets_mode_to = "default";
};
"T" = {
cmd = "";
@@ -89,57 +73,44 @@ in {
};
"2" = {
cmd = "fish_vi_arg_digit 2";
- sets_mode_to = "default";
};
"W" = {
cmd = "fish_vi_exec_motion forward-bigword-vi";
- sets_mode_to = "default";
};
"$" = {
cmd = "fish_vi_exec_motion end-of-line";
- sets_mode_to = "default";
};
"0" = {
cmd = "fish_vi_exec_motion beginning-of-line";
- sets_mode_to = "default";
};
"8" = {
cmd = "fish_vi_arg_digit 8";
- sets_mode_to = "default";
};
"g" = {
"E" = {
cmd = "fish_vi_exec_motion backward-bigword-end";
- sets_mode_to = "default";
};
"e" = {
cmd = "fish_vi_exec_motion backward-word-end";
- sets_mode_to = "default";
};
};
"w" = {
cmd = "fish_vi_exec_motion forward-word-vi";
- sets_mode_to = "default";
};
"b" = {
cmd = "fish_vi_exec_motion backward-word";
- sets_mode_to = "default";
};
"6" = {
cmd = "fish_vi_arg_digit 6";
- sets_mode_to = "default";
};
"y" = {
cmd = "fish_vi_exec_motion --linewise";
- sets_mode_to = "default";
};
"l" = {
cmd = "fish_vi_exec_motion forward-char";
- sets_mode_to = "default";
};
"1" = {
cmd = "fish_vi_arg_digit 1";
- sets_mode_to = "default";
};
"f" = {
cmd = "";
@@ -147,254 +118,175 @@ in {
};
"3" = {
cmd = "fish_vi_arg_digit 3";
- sets_mode_to = "default";
- };
- };
- "T" = {
- "" = {
- cmd = "get-key fish_vi_exec_motion commandline --backward-jump-till=$fish_key set -eg fish_key";
- sets_mode_to = "default";
- };
- };
- "f" = {
- "" = {
- cmd = "get-key fish_vi_exec_motion commandline --forward-jump=$fish_key set -eg fish_key";
- sets_mode_to = "default";
};
};
"insert" = {
"alt-up" = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"alt-v" = {
cmd = "edit_command_buffer";
- sets_mode_to = "default";
};
"pageup" = {
cmd = "beginning-of-history";
- sets_mode_to = "default";
};
">" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"left" = {
cmd = "backward-char";
- sets_mode_to = "default";
};
- "\\e\\[1\\;9C" = {
+ ${escPlus "1;9C"} = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"ctrl-k" = {
cmd = "kill-line";
- sets_mode_to = "default";
};
"&" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"shift-delete" = {
- cmd = "history-delete or backward-delete-char";
- sets_mode_to = "default";
+ cmd = ["history-delete" "or" "backward-delete-char"];
};
"alt-l" = {
cmd = "__fish_list_current_token";
- sets_mode_to = "default";
};
"shift-tab" = {
cmd = "complete-and-search";
- sets_mode_to = "default";
};
"space" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"up" = {
cmd = "up-or-search";
- sets_mode_to = "default";
};
"alt-#" = {
cmd = "__fish_toggle_comment_commandline";
- sets_mode_to = "default";
};
"tab" = {
cmd = "complete";
- sets_mode_to = "default";
};
"alt-h" = {
cmd = "__fish_man_page";
- sets_mode_to = "default";
};
- "\\e\\[1\\;9A" = {
+ ${escPlus "1;9A"} = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"ctrl-u" = {
cmd = "backward-kill-line";
- sets_mode_to = "default";
};
"shift-backspace" = {
cmd = "backward-delete-char";
- sets_mode_to = "default";
};
"alt-enter" = {
- cmd = "commandline -i \\n (commandline --search-field >/dev/null && echo --search-field) expand-abbr";
- sets_mode_to = "default";
+ cmd = [
+ ''commandline -i \n (commandline --search-field >/dev/null && echo --search-field)''
+ "expand-abbr"
+ ];
};
"ctrl-w" = {
cmd = "backward-kill-path-component";
- sets_mode_to = "default";
};
"ctrl-right" = {
cmd = "forward-token";
- sets_mode_to = "default";
};
"pagedown" = {
cmd = "end-of-history";
- sets_mode_to = "default";
};
"alt-down" = {
cmd = "history-token-search-forward";
- sets_mode_to = "default";
};
"down" = {
cmd = "down-or-search";
- sets_mode_to = "default";
};
"ctrl-n" = {
cmd = "accept-autosuggestion";
- sets_mode_to = "default";
};
"enter" = {
cmd = "execute";
- sets_mode_to = "default";
};
"ctrl-m" = {
cmd = "execute";
- sets_mode_to = "default";
};
"shift-space" = {
- cmd = ''
- commandline -i " " (commandline --search-field >/dev/null && echo --search-field) expand-abbr
- '';
- sets_mode_to = "default";
+ cmd = [
+ ''
+ commandline -i " " (commandline --search-field >/dev/null && echo --search-field)
+ ''
+ "expand-abbr"
+ ];
};
"ctrl-s" = {
cmd = "pager-toggle-search";
- sets_mode_to = "default";
};
"ctrl-i" = {
cmd = "complete";
- sets_mode_to = "default";
};
"shift-right" = {
cmd = "forward-bigword";
- sets_mode_to = "default";
};
"end" = {
cmd = "end-of-line";
- sets_mode_to = "default";
};
")" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"ctrl-x" = {
cmd = "fish_clipboard_copy";
- sets_mode_to = "default";
};
- "\\e\\[1\\;9D" = {
+ ${escPlus "1;9D"} = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
"alt-e" = {
cmd = "edit_command_buffer";
- sets_mode_to = "default";
};
"alt-p" = {
cmd = "__fish_paginate";
- sets_mode_to = "default";
};
"f1" = {
cmd = "__fish_man_page";
- sets_mode_to = "default";
};
"shift-left" = {
cmd = "backward-bigword";
- sets_mode_to = "default";
};
"ctrl-l" = {
- cmd = "status test-terminal-feature scroll-content-up && commandline -f scrollback-push clear-screen";
- sets_mode_to = "default";
+ cmd = [
+ "status test-terminal-feature scroll-content-up && commandline -f scrollback-push"
+ "clear-screen"
+ ];
};
"alt-y" = {
cmd = "yank-pop";
- sets_mode_to = "default";
};
"<" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"alt-w" = {
cmd = "__fish_whatis_current_token";
- sets_mode_to = "default";
};
"right" = {
cmd = "forward-char";
- sets_mode_to = "default";
};
"shift-enter" = {
- cmd = "commandline -i \\n (commandline --search-field >/dev/null && echo --search-field) expand-abbr";
- sets_mode_to = "default";
+ cmd = [
+ ''commandline -i \n (commandline --search-field >/dev/null && echo --search-field)''
+ "expand-abbr"
+ ];
};
- "\\e\\[1\\;9B" = {
+ ${escPlus "1;9B"} = {
cmd = "history-token-search-forward";
- sets_mode_to = "default";
- };
- "escape" = {
- cmd = ''
- if commandline -P
- commandline -f cancel
- else
- set fish_bind_mode default
- if test \(count \(commandline --cut-at-cursor \| tail -c2\)\) != 2
- commandline -f backward-char
- end
- commandline -f repaint-mode
- end
- '';
- sets_mode_to = "default";
- };
- "ctrl-\\[" = {
- cmd = ''
- if commandline -P
- commandline -f cancel
- else
- set fish_bind_mode default
- if test \(count \(commandline --cut-at-cursor \| tail -c2\)\) != 2
- commandline -f backward-char
- end
- commandline -f repaint-mode
- end
- '';
};
"|" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"alt-b" = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
"ctrl-enter" = {
cmd = "execute";
- sets_mode_to = "default";
};
"alt-f" = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"alt-s" = {
cmd = ''
@@ -405,54 +297,42 @@ in {
end;
end
'';
- sets_mode_to = "default";
};
"ctrl-space" = {
cmd = ''
test -n "$(commandline)"
&& commandline -i " " (commandline --search-field >/dev/null && echo --search-field)
'';
- sets_mode_to = "default";
};
"ctrl-left" = {
cmd = "backward-token";
- sets_mode_to = "default";
};
"ctrl-y" = {
cmd = "yank";
- sets_mode_to = "default";
};
"alt-." = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"ctrl-j" = {
cmd = "execute";
- sets_mode_to = "default";
};
"alt-left" = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
"ctrl-h" = {
cmd = "backward-delete-char";
- sets_mode_to = "default";
};
"alt-o" = {
cmd = "__fish_preview_current_file";
- sets_mode_to = "default";
};
"delete" = {
cmd = "delete-char";
- sets_mode_to = "default";
};
"" = {
cmd = "self-insert";
- sets_mode_to = "default";
};
"ctrl-d" = {
cmd = "delete-or-exit";
- sets_mode_to = "default";
};
"alt-d" = {
cmd = ''
@@ -462,38 +342,45 @@ in {
commandline -f kill-word;
end
'';
- sets_mode_to = "default";
};
"alt-right" = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"ctrl-v" = {
cmd = "fish_clipboard_paste";
- sets_mode_to = "default";
};
"home" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
";" = {
- cmd = "self-insert expand-abbr";
- sets_mode_to = "default";
+ cmd = ["self-insert" "expand-abbr"];
};
"backspace" = {
cmd = "backward-delete-char";
- sets_mode_to = "default";
};
"ctrl-c" = {
cmd = "clear-commandline";
- sets_mode_to = "default";
};
+ "escape" = {
+ cmd = ''
+ if commandline -P
+ commandline -f cancel
+ else
+ set fish_bind_mode default
+ if test (count (commandline --cut-at-cursor | tail -c2)) != 2
+ commandline -f backward-char
+ end
+ commandline -f repaint-mode
+ end
+ '';
+ };
+ "ctrl-\\[" = self.insert.escape;
};
"default" = {
- # "\\e\\[1\\;9A" = {cmd = "history-token-search-backward";};
- # "\\e\\[1\\;9B" = {cmd = "history-token-search-forward";};
- # "\\e\\[1\\;9C" = {cmd = "nextd-or-forward-word";};
- # "\\e\\[1\\;9D" = {cmd = "prevd-or-backward-word";};
+ # ${escPlus "1;9A"} = {cmd = "history-token-search-backward";};
+ # ${escPlus "1;9B"} = {cmd = "history-token-search-forward";};
+ # ${escPlus "1;9C"} = {cmd = "nextd-or-forward-word";};
+ # ${escPlus "1;9D"} = {cmd = "prevd-or-backward-word";};
"down" = {cmd = "down-or-search";};
"ctrl-y" = {cmd = "yank";};
@@ -532,7 +419,7 @@ in {
"alt-b" = {cmd = fromInsert "alt-b";};
"alt-right" = {cmd = fromInsert "alt-right";};
"alt-y" = {cmd = fromInsert "alt-y";};
- "ctrl-[" = {cmd = "set -g __fish_vi_count";};
+ "ctrl-\\[" = {cmd = "set -g __fish_vi_count";};
"ctrl-i" = {cmd = fromInsert "ctrl-i";};
"home" = {cmd = fromInsert "home";};
"ctrl-s" = {cmd = fromInsert "ctrl-s";};
@@ -547,17 +434,19 @@ in {
"alt-." = {cmd = "history-token-search-backward";};
"ctrl-right" = {cmd = "forward-token";};
"ctrl-c" = {
- cmd = "clear-commandline repaint-mode";
+ cmd = ["clear-commandline" "repaint-mode"];
sets_mode_to = "insert";
};
"alt-o" = {cmd = "__fish_preview_current_file";};
"x" = {cmd = "__fish_vi_delete_char";};
"D" = {cmd = "kill-line";};
- "j" = {cmd = "fish_vi_run_count down-or-search";};
+ "j" = {
+ cmd = "fish_vi_run_count down-or-search";
+ };
"f" = {cmd = "forward-jump";};
"s" = {
- cmd = "delete-char repaint-mode";
+ cmd = ["delete-char" "repaint-mode"];
sets_mode_to = "insert";
};
"%" = {cmd = "jump-to-matching-bracket";};
@@ -571,7 +460,7 @@ in {
"alt-#" = {cmd = "__fish_toggle_comment_commandline";};
"up" = {cmd = "up-or-search";};
"S" = {
- cmd = "kill-inner-line repaint-mode";
+ cmd = ["kill-inner-line" "repaint-mode"];
sets_mode_to = "insert";
};
"ctrl-j" = {
@@ -596,11 +485,25 @@ in {
"y" = {
"y" = {cmd = "fish_clipboard_copy";};
};
- "p" = {cmd = "set -g fish_cursor_end_mode exclusive forward-char set -g fish_cursor_end_mode inclusive fish_clipboard_paste";};
+ "p" = {
+ cmd = [
+ "set -g fish_cursor_end_mode exclusive"
+ "forward-char"
+ "set -g fish_cursor_end_mode inclusive"
+ "fish_clipboard_paste"
+ ];
+ };
"Y" = {cmd = "fish_clipboard_copy";};
};
"*" = {
- "p" = {cmd = "set -g fish_cursor_end_mode exclusive forward-char set -g fish_cursor_end_mode inclusive fish_clipboard_paste";};
+ "p" = {
+ cmd = [
+ "set -g fish_cursor_end_mode exclusive"
+ "forward-char"
+ "set -g fish_cursor_end_mode inclusive"
+ "fish_clipboard_paste"
+ ];
+ };
"P" = {cmd = "fish_clipboard_paste";};
"Y" = {cmd = "fish_clipboard_copy";};
"y" = {
@@ -609,7 +512,9 @@ in {
};
};
"t" = {cmd = "forward-jump-till";};
- "~" = {cmd = "togglecase-char forward-single-char";};
+ "~" = {
+ cmd = ["togglecase-char" "forward-single-char"];
+ };
"i" = {
cmd = "repaint-mode";
sets_mode_to = "insert";
@@ -619,12 +524,16 @@ in {
"l" = {cmd = "fish_vi_run_count forward-char";};
"T" = {cmd = "backward-jump-till";};
"/" = {
- cmd = "history-pager repaint-mode";
+ cmd = ["history-pager" "repaint-mode"];
sets_mode_to = "insert";
};
"8" = {cmd = "fish_vi_arg_digit 8";};
"a" = {
- cmd = "set fish_cursor_end_mode exclusive forward-single-char repaint-mode";
+ cmd = [
+ "set fish_cursor_end_mode exclusive"
+ "forward-single-char"
+ "repaint-mode"
+ ];
sets_mode_to = "insert";
};
"R" = {
@@ -635,7 +544,11 @@ in {
"G" = {cmd = "end-of-buffer";};
"[" = {cmd = "history-token-search-backward";};
"o" = {
- cmd = "set fish_cursor_end_mode exclusive insert-line-under repaint-mode";
+ cmd = [
+ "set fish_cursor_end_mode exclusive"
+ "insert-line-under"
+ "repaint-mode"
+ ];
sets_mode_to = "insert";
};
"W" = {cmd = "fish_vi_run_count forward-bigword-vi";};
@@ -656,103 +569,185 @@ in {
"$" = {cmd = "kill-line";};
"a" = {
"w" = {cmd = "kill-a-word";};
- "b" = {cmd = "jump-to-matching-bracket and jump-to-matching-bracket and begin-selection jump-to-matching-bracket kill-selection end-selection";};
+ "b" = {
+ cmd = [
+ "jump-to-matching-bracket"
+ "and"
+ "jump-to-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-to-matching-bracket"
+ "kill-selection"
+ "end-selection"
+ ];
+ };
"W" = {cmd = "kill-a-bigword";};
};
"i" = {
"w" = {cmd = "kill-inner-word";};
"W" = {cmd = "kill-inner-bigword";};
- "b" = {cmd = "jump-till-matching-bracket and jump-till-matching-bracket and begin-selection jump-till-matching-bracket kill-selection end-selection";};
+ "b" = {
+ cmd = [
+ "jump-till-matching-bracket"
+ "and"
+ "jump-till-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-till-matching-bracket"
+ "kill-selection"
+ "end-selection"
+ ];
+ };
};
- "comma" = {cmd = "begin-selection repeat-jump-reverse kill-selection end-selection";};
- ";" = {cmd = "begin-selection repeat-jump kill-selection end-selection";};
+ "comma" = {
+ cmd = [
+ "begin-selection"
+ "repeat-jump-reverse"
+ "kill-selection"
+ "end-selection"
+ ];
+ };
+ ";" = {cmd = ["begin-selection" "repeat-jump" "kill-selection" "end-selection"];};
"0" = {cmd = "backward-kill-line";};
"^" = {cmd = "backward-kill-line";};
};
"1" = {cmd = "fish_vi_arg_digit 1";};
"F" = {cmd = "backward-jump";};
- "Y" = {cmd = "kill-whole-line yank";};
+ "Y" = {cmd = ["kill-whole-line" "yank"];};
"E" = {cmd = "fish_vi_run_count forward-bigword-end";};
"3" = {cmd = "fish_vi_arg_digit 3";};
- "J" = {cmd = "end-of-line delete-char";};
+ "J" = {
+ cmd = ["end-of-line" "delete-char"];
+ };
"u" = {cmd = "undo";};
"c" = {
"^" = {
- cmd = "backward-kill-line repaint-mode";
+ cmd = ["backward-kill-line" "repaint-mode"];
sets_mode_to = "insert";
};
"i" = {
"w" = {
- cmd = "kill-inner-word repaint-mode";
+ cmd = ["kill-inner-word" "repaint-mode"];
sets_mode_to = "insert";
};
"W" = {
- cmd = "kill-inner-bigword repaint-mode";
+ cmd = ["kill-inner-bigword" "repaint-mode"];
sets_mode_to = "insert";
};
"b" = {
- cmd = "jump-till-matching-bracket and jump-till-matching-bracket and begin-selection jump-till-matching-bracket kill-selection end-selection";
+ cmd = [
+ "jump-till-matching-bracket"
+ "and"
+ "jump-till-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-till-matching-bracket"
+ "kill-selection"
+ "end-selection"
+ ];
sets_mode_to = "insert";
};
};
"a" = {
"W" = {
- cmd = "kill-a-bigword repaint-mode";
+ cmd = ["kill-a-bigword" "repaint-mode"];
sets_mode_to = "insert";
};
"w" = {
- cmd = "kill-a-word repaint-mode";
+ cmd = ["kill-a-word" "repaint-mode"];
sets_mode_to = "insert";
};
"b" = {
- cmd = "jump-to-matching-bracket and jump-to-matching-bracket and begin-selection jump-to-matching-bracket kill-selection end-selection";
+ cmd = [
+ "jump-till-matching-bracket"
+ "and"
+ "jump-till-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-to-matching-bracket"
+ "kill-selection"
+ "end-selection"
+ ];
sets_mode_to = "insert";
};
};
"$" = {
- cmd = "kill-line repaint-mode";
+ cmd = ["kill-line" "repaint-mode"];
sets_mode_to = "insert";
};
"0" = {
- cmd = "backward-kill-line repaint-mode";
+ cmd = ["backward-kill-line" "repaint-mode"];
sets_mode_to = "insert";
};
};
"_" = {cmd = "beginning-of-line";};
"A" = {
- cmd = "set fish_cursor_end_mode exclusive end-of-line repaint-mode";
+ cmd = [
+ "set fish_cursor_end_mode exclusive"
+ "end-of-line"
+ "repaint-mode"
+ ];
sets_mode_to = "insert";
};
"I" = {
- cmd = "beginning-of-line repaint-mode";
+ cmd = ["beginning-of-line" "repaint-mode"];
sets_mode_to = "insert";
};
"$" = {cmd = "end-of-line";};
"X" = {cmd = "__fish_vi_backward_delete_char";};
"B" = {cmd = "fish_vi_run_count backward-bigword";};
"y" = {
- "0" = {cmd = "backward-kill-line yank";};
+ "0" = {cmd = ["backward-kill-line" "yank"];};
"i" = {
- "W" = {cmd = "kill-inner-bigword yank";};
- "w" = {cmd = "kill-inner-word yank";};
- "b" = {cmd = "jump-till-matching-bracket and jump-till-matching-bracket and begin-selection jump-till-matching-bracket fish_vi_yank_selection end-selection";};
+ "W" = {cmd = ["kill-inner-bigword" "yank"];};
+ "w" = {cmd = ["kill-inner-word" "yank"];};
+ "b" = {
+ cmd = [
+ "jump-till-matching-bracket"
+ "and"
+ "jump-till-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-till-matching-bracket"
+ "fish_vi_yank_selection"
+ "end-selection"
+ ];
+ };
};
"a" = {
- "W" = {cmd = "kill-a-bigword yank";};
- "b" = {cmd = "jump-to-matching-bracket and jump-to-matching-bracket and begin-selection jump-to-matching-bracket fish_vi_yank_selection end-selection";};
- "w" = {cmd = "kill-a-word yank";};
+ "W" = {cmd = ["kill-a-bigword" "yank"];};
+ "b" = {
+ cmd = [
+ "jump-till-matching-bracket"
+ "and"
+ "jump-till-matching-bracket"
+ "and"
+ "begin-selection"
+ "jump-to-matching-bracket"
+ "fish_vi_yank_selection"
+ "end-selection"
+ ];
+ };
+ "w" = {cmd = ["kill-a-word" "yank"];};
};
- "^" = {cmd = "backward-kill-line yank";};
- "$" = {cmd = "kill-line yank";};
+ "^" = {cmd = ["backward-kill-line" "yank"];};
+ "$" = {cmd = ["kill-line" "yank"];};
+ };
+ "p" = {
+ cmd = [
+ "set -g fish_cursor_end_mode exclusive"
+ "forward-char"
+ "set -g fish_cursor_end_mode inclusive"
+ "yank"
+ ];
};
- "p" = {cmd = "set -g fish_cursor_end_mode exclusive forward-char set -g fish_cursor_end_mode inclusive yank";};
"#" = {cmd = "__fish_toggle_comment_commandline";};
"v" = {
- cmd = "begin-selection repaint-mode";
+ cmd = ["begin-selection" "repaint-mode"];
sets_mode_to = "visual";
};
"O" = {
- cmd = "set fish_cursor_end_mode exclusive insert-line-over repaint-mode";
+ cmd = ["set fish_cursor_end_mode exclusive" "insert-line-over" "repaint-mode"];
sets_mode_to = "insert";
};
"2" = {cmd = "fish_vi_arg_digit 2";};
@@ -769,7 +764,7 @@ in {
};
"7" = {cmd = "fish_vi_arg_digit 7";};
"C" = {
- cmd = "kill-line repaint-mode";
+ cmd = ["kill-line" "repaint-mode"];
sets_mode_to = "insert";
};
"h" = {cmd = "fish_vi_run_count backward-char";};
@@ -777,454 +772,400 @@ in {
"visual" = {
"alt-down" = {
cmd = "history-token-search-forward";
- sets_mode_to = "default";
- };
- "ctrl-c" = {
- cmd = "end-selection repaint-mode";
- sets_mode_to = "default";
};
"alt-h" = {
cmd = "__fish_man_page";
- sets_mode_to = "default";
};
"l" = {
cmd = "forward-char";
- sets_mode_to = "default";
};
"T" = {
cmd = "backward-jump-till";
- sets_mode_to = "default";
};
"e" = {
cmd = "forward-word-end";
- sets_mode_to = "default";
};
"right" = {
cmd = "forward-char";
- sets_mode_to = "default";
};
"t" = {
cmd = "forward-jump-till";
- sets_mode_to = "default";
};
"s" = {
- cmd = "kill-selection end-selection repaint-mode";
+ cmd = ["kill-selection" "end-selection" "repaint-mode"];
sets_mode_to = "insert";
};
"alt-#" = {
cmd = "__fish_toggle_comment_commandline";
- sets_mode_to = "default";
};
"_" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
"%" = {
cmd = "jump-to-matching-bracket";
- sets_mode_to = "default";
};
"ctrl-s" = {
cmd = "pager-toggle-search";
- sets_mode_to = "default";
};
"ctrl-w" = {
cmd = "backward-kill-path-component";
- sets_mode_to = "default";
};
"alt-o" = {
cmd = "__fish_preview_current_file";
- sets_mode_to = "default";
};
"left" = {
cmd = "backward-char";
- sets_mode_to = "default";
};
"shift-left" = {
cmd = "backward-bigword";
- sets_mode_to = "default";
};
"alt-p" = {
cmd = "__fish_paginate";
- sets_mode_to = "default";
};
"F" = {
cmd = "backward-jump";
- sets_mode_to = "default";
};
"ctrl-left" = {
cmd = "backward-token";
- sets_mode_to = "default";
};
"b" = {
cmd = "backward-word";
- sets_mode_to = "default";
};
"f1" = {
cmd = "__fish_man_page";
- sets_mode_to = "default";
};
"shift-delete" = {
- cmd = "history-delete or backward-delete-char";
- sets_mode_to = "default";
+ cmd = ["history-delete" "or" "backward-delete-char"];
};
"\"" = {
"+" = {
"y" = {
- cmd = "fish_clipboard_copy; commandline -f end-selection repaint-mode";
+ cmd = ["fish_clipboard_copy; commandline -f end-selection" "repaint-mode"];
sets_mode_to = "default";
};
};
"*" = {
"y" = {
- cmd = "fish_clipboard_copy; commandline -f end-selection repaint-mode";
+ cmd = ["fish_clipboard_copy; commandline -f end-selection" "repaint-mode"];
sets_mode_to = "default";
};
};
};
"shift-tab" = {
cmd = "complete-and-search";
- sets_mode_to = "default";
};
"alt-b" = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
"#" = {
cmd = "__fish_toggle_comment_commandline";
- sets_mode_to = "default";
};
"~" = {
- cmd = "togglecase-selection end-selection repaint-mode";
+ cmd = ["togglecase-selection" "end-selection" "repaint-mode"];
sets_mode_to = "default";
};
"y" = {
- cmd = "fish_vi_yank_selection end-selection repaint-mode";
+ cmd = ["fish_vi_yank_selection" "end-selection" "repaint-mode"];
sets_mode_to = "default";
};
"f" = {
cmd = "forward-jump";
- sets_mode_to = "default";
};
"x" = {
- cmd = "kill-selection end-selection repaint-mode";
+ cmd = ["kill-selection" "end-selection" "repaint-mode"];
+ sets_mode_to = "default";
+ };
+ "X" = {
+ cmd = ["kill-whole-line" "end-selection" "repaint-mode"];
sets_mode_to = "default";
};
"alt-y" = {
cmd = "yank-pop";
- sets_mode_to = "default";
};
"$" = {
cmd = "end-of-line";
- sets_mode_to = "default";
};
";" = {
cmd = "repeat-jump";
- sets_mode_to = "default";
};
"W" = {
cmd = "forward-bigword-vi";
- sets_mode_to = "default";
};
"w" = {
cmd = "forward-word-vi";
- sets_mode_to = "default";
};
"j" = {
cmd = "down-line";
- sets_mode_to = "default";
};
"k" = {
cmd = "up-line";
- sets_mode_to = "default";
};
"end" = {
cmd = "end-of-line";
- sets_mode_to = "default";
};
"down" = {
cmd = "down-or-search";
- sets_mode_to = "default";
};
"alt-up" = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"i" = {
- cmd = "end-selection repaint-mode";
+ cmd = ["end-selection" "repaint-mode"];
sets_mode_to = "insert";
};
"g" = {
"^" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
"e" = {
cmd = "backward-word-end";
- sets_mode_to = "default";
- };
- "u" = {
- cmd = "downcase-selection end-selection repaint-mode";
- sets_mode_to = "default";
};
"$" = {
cmd = "end-of-line";
- sets_mode_to = "default";
};
"U" = {
- cmd = "upcase-selection end-selection repaint-mode";
+ cmd = ["upcase-selection" "end-selection" "repaint-mode"];
+ sets_mode_to = "default";
+ };
+ "u" = {
+ cmd = ["downcase-selection" "end-selection" "repaint-mode"];
sets_mode_to = "default";
};
"E" = {
cmd = "backward-bigword-end";
- sets_mode_to = "default";
};
};
"I" = {
- cmd = "end-selection beginning-of-line repaint-mode";
+ cmd = ["end-selection" "beginning-of-line" "repaint-mode"];
sets_mode_to = "insert";
};
"alt-." = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"home" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
"alt-l" = {
cmd = "__fish_list_current_token";
- sets_mode_to = "default";
};
"ctrl-x" = {
cmd = "fish_clipboard_copy";
- sets_mode_to = "default";
};
"alt-s" = {
- cmd = "for cmd in sudo doas please run0; if command -q $cmd; fish_commandline_prepend $cmd; break; end; end";
- sets_mode_to = "default";
+ cmd = ''
+ for cmd in sudo doas please run0;
+ if command -q $cmd;
+ fish_commandline_prepend $cmd;
+ break;
+ end;
+ end
+ '';
};
"o" = {
- cmd = "swap-selection-start-stop repaint-mode";
- sets_mode_to = "default";
+ cmd = ["swap-selection-start-stop" "repaint-mode"];
};
- "ctrl-[" = {
- cmd = "end-selection repaint-mode";
- sets_mode_to = "default";
- };
- "X" = {
- cmd = "kill-whole-line end-selection repaint-mode";
- sets_mode_to = "default";
- };
- "\\e\\[1\\;9B" = {
+ ${escPlus "1;9B"} = {
cmd = "history-token-search-forward";
- sets_mode_to = "default";
};
"pageup" = {
cmd = "beginning-of-history";
- sets_mode_to = "default";
};
"ctrl-l" = {
- cmd = "status test-terminal-feature scroll-content-up && commandline -f scrollback-push clear-screen";
- sets_mode_to = "default";
+ cmd = [
+ "status test-terminal-feature scroll-content-up && commandline -f scrollback-push"
+ "clear-screen"
+ ];
};
"up" = {
cmd = "up-or-search";
- sets_mode_to = "default";
};
"ctrl-u" = {
cmd = "backward-kill-line";
- sets_mode_to = "default";
};
"h" = {
cmd = "backward-char";
- sets_mode_to = "default";
};
"alt-right" = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"ctrl-y" = {
cmd = "yank";
- sets_mode_to = "default";
};
"v" = {
- cmd = "end-selection repaint-mode";
+ cmd = ["end-selection" "repaint-mode"];
sets_mode_to = "default";
};
- "\\e\\[1\\;9D" = {
+ ${escPlus "1;9D"} = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
- "\\e\\[1\\;9C" = {
+ ${escPlus "1;9C"} = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"0" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
"ctrl-k" = {
cmd = "kill-line";
- sets_mode_to = "default";
};
"alt-v" = {
cmd = "edit_command_buffer";
- sets_mode_to = "default";
};
"ctrl-v" = {
cmd = "fish_clipboard_paste";
- sets_mode_to = "default";
};
"ctrl-i" = {
cmd = "complete";
- sets_mode_to = "default";
};
"d" = {
- cmd = "kill-selection end-selection backward-char repaint-mode";
+ cmd = [
+ "kill-selection"
+ "end-selection"
+ "backward-char"
+ "repaint-mode"
+ ];
sets_mode_to = "default";
};
"^" = {
cmd = "beginning-of-line";
- sets_mode_to = "default";
};
"alt-f" = {
cmd = "nextd-or-forward-word";
- sets_mode_to = "default";
};
"ctrl-right" = {
cmd = "forward-token";
- sets_mode_to = "default";
};
"alt-w" = {
cmd = "__fish_whatis_current_token";
- sets_mode_to = "default";
};
- "\\e\\[1\\;9A" = {
+ ${escPlus "1;9A"} = {
cmd = "history-token-search-backward";
- sets_mode_to = "default";
};
"shift-right" = {
cmd = "forward-bigword";
- sets_mode_to = "default";
};
"E" = {
cmd = "forward-bigword-end";
- sets_mode_to = "default";
};
"tab" = {
cmd = "complete";
- sets_mode_to = "default";
};
"B" = {
cmd = "backward-bigword";
- sets_mode_to = "default";
};
"alt-e" = {
cmd = "edit_command_buffer";
- sets_mode_to = "default";
};
"alt-d" = {
cmd = fromInsert "alt-d";
- sets_mode_to = "default";
};
"pagedown" = {
cmd = "end-of-history";
- sets_mode_to = "default";
};
"c" = {
- cmd = "kill-selection end-selection repaint-mode";
+ cmd = ["kill-selection" "end-selection" "repaint-mode"];
sets_mode_to = "insert";
};
"alt-left" = {
cmd = "prevd-or-backward-word";
- sets_mode_to = "default";
};
"comma" = {
cmd = "repeat-jump-reverse";
- sets_mode_to = "default";
};
"ctrl-d" = {
cmd = "delete-or-exit";
- sets_mode_to = "default";
};
"escape" = {
- cmd = "end-selection repaint-mode";
+ cmd = ["end-selection" "repaint-mode"];
sets_mode_to = "default";
};
+ "ctrl-\\[" = self.visual.escape;
+ "ctrl-c" = self.visual.escape;
+ };
+ "T" = {
+ "" = {
+ cmd = self.t."".cmd;
+ };
+ };
+ "f" = {
+ "" = {
+ cmd = self.F."".cmd;
+ };
};
"F" = {
"" = {
- cmd = "get-key fish_vi_exec_motion commandline --backward-jump=$fish_key set -eg fish_key";
- sets_mode_to = "default";
+ cmd = [
+ "get-key"
+ "fish_vi_exec_motion commandline --backward-jump=$fish_key"
+ "set -eg fish_key"
+ ];
};
};
"t" = {
"" = {
- cmd = "get-key fish_vi_exec_motion commandline --forward-jump-till=$fish_key set -eg fish_key";
- sets_mode_to = "default";
+ cmd = [
+ "get-key"
+ "fish_vi_exec_motion commandline --forward-jump-till=$fish_key"
+ "set -eg fish_key"
+ ];
};
};
"replace" = {
- "escape" = {
- cmd = "cancel repaint-mode";
- sets_mode_to = "default";
- };
"#" = {
cmd = "__fish_toggle_comment_commandline";
- sets_mode_to = "default";
};
"ctrl-m" = {
- cmd = "execute repaint-mode";
+ cmd = ["execute" "repaint-mode"];
sets_mode_to = "insert";
};
"shift-backspace" = {
cmd = "backward-char";
- sets_mode_to = "default";
- };
- "ctrl-[" = {
- cmd = "cancel repaint-mode";
- sets_mode_to = "default";
};
"enter" = {
- cmd = "execute repaint-mode";
+ cmd = ["execute" "repaint-mode"];
sets_mode_to = "insert";
};
"" = {
- cmd = "delete-char self-insert";
- sets_mode_to = "default";
+ cmd = ["delete-char" "self-insert"];
};
"backspace" = {
cmd = "backward-char";
- sets_mode_to = "default";
};
"ctrl-j" = {
- cmd = "execute repaint-mode";
+ cmd = ["execute" "repaint-mode"];
sets_mode_to = "insert";
};
- };
- "replace_one" = {
+ "ctrl-\\[" = self.replace.escape;
"escape" = {
- cmd = "cancel repaint-mode";
+ cmd = ["cancel" "repaint-mode"];
sets_mode_to = "default";
};
+ };
+ "replace_one" = {
"" = {
- cmd = "set -g fish_cursor_end_mode exclusive delete-char self-insert backward-char repaint-mode set -g fish_cursor_end_mode inclusive";
- sets_mode_to = "default";
- };
- "ctrl-j" = {
- cmd = "set -g fish_cursor_end_mode exclusive commandline -f delete-char; commandline -i \\n; commandline -f backward-char repaint-mode set -g fish_cursor_end_mode inclusive";
+ cmd = [
+ "set -g fish_cursor_end_mode exclusive"
+ "delete-char"
+ "self-insert"
+ "backward-char"
+ "repaint-mode"
+ "set -g fish_cursor_end_mode inclusive"
+ ];
sets_mode_to = "default";
};
"enter" = {
- cmd = "set -g fish_cursor_end_mode exclusive commandline -f delete-char; commandline -i \\n; commandline -f backward-char repaint-mode set -g fish_cursor_end_mode inclusive";
+ cmd = [
+ "set -g fish_cursor_end_mode exclusive"
+ ''commandline -f delete-char; commandline -i \n; commandline -f backward-char''
+ "repaint-mode"
+ "set -g fish_cursor_end_mode inclusive"
+ ];
sets_mode_to = "default";
};
- "ctrl-[" = {
- cmd = "cancel repaint-mode";
- sets_mode_to = "default";
- };
- "ctrl-m" = {
- cmd = "set -g fish_cursor_end_mode exclusive commandline -f delete-char; commandline -i \\n; commandline -f backward-char repaint-mode set -g fish_cursor_end_mode inclusive";
+ "ctrl-j" = self.replace_one.enter;
+ "ctrl-m" = self.replace_one.enter;
+ "ctrl-\\[" = self.replace_one.escape;
+ "escape" = {
+ cmd = ["cancel" "repaint-mode"];
sets_mode_to = "default";
};
};
diff --git a/modules/by-name/fi/fish/module.nix b/modules/by-name/fi/fish/module.nix
index 7f16fc08..6f13e39f 100644
--- a/modules/by-name/fi/fish/module.nix
+++ b/modules/by-name/fi/fish/module.nix
@@ -30,22 +30,46 @@
mkBinding = mode: base_key: binding: let
sets_mode_to =
if binding ? sets_mode_to
- then "--sets-mode ${binding.sets_mode_to}"
+ then "--sets-mode ${binding.sets_mode_to} "
else "";
-
- key = lib.escape ["$" "*"] base_key;
in
if binding ? cmd
- then ''
- bind --mode "${mode}" ${sets_mode_to} --preset ${lib.escapeShellArg key} ${lib.escapeShellArg binding.cmd}
+ then let
+ mkCmd = cmd: "'${cmd}'";
+ escaped_key =
+ if base_key == ""
+ then ''""''
+ else
+ lib.escape [
+ "\""
+ "("
+ ")"
+ "$"
+ ";"
+ "*"
+ "&"
+ "|"
+ "~"
+ "<"
+ ">"
+ "^"
+ ]
+ base_key;
+ escaped_cmd =
+ if builtins.isList binding.cmd
+ then builtins.concatStringsSep " " (builtins.map mkCmd binding.cmd)
+ else mkCmd binding.cmd;
+ in ''
+ bind --mode "${mode}" ${sets_mode_to}--preset ${escaped_key} ${escaped_cmd}
''
else
builtins.concatStringsSep "" (lib.mapAttrsToList
- (new_key: value: mkBinding mode "${key + "," + new_key}" value)
+ (new_key: value: mkBinding mode "${base_key + "," + new_key}" value)
binding);
mkMode = mode: attr: builtins.concatStringsSep "" (lib.mapAttrsToList (mkBinding mode) attr);
keymappings =
''
+ fish_vi_key_bindings
bind --erase --all
''
+ builtins.concatStringsSep "\n" (lib.mapAttrsToList mkMode keymappings_raw);