summaryrefslogtreecommitdiffstats
path: root/modules/by-name/fi/fish/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/fi/fish/module.nix')
-rw-r--r--modules/by-name/fi/fish/module.nix46
1 files changed, 38 insertions, 8 deletions
diff --git a/modules/by-name/fi/fish/module.nix b/modules/by-name/fi/fish/module.nix
index 7f16fc08..7d423bec 100644
--- a/modules/by-name/fi/fish/module.nix
+++ b/modules/by-name/fi/fish/module.nix
@@ -30,25 +30,55 @@
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 =
''
- bind --erase --all
+ function fish_my_key_bindings
+ fish_vi_key_bindings
+ bind --erase --all --preset
''
- + builtins.concatStringsSep "\n" (lib.mapAttrsToList mkMode keymappings_raw);
+ + builtins.concatStringsSep "\n" (lib.mapAttrsToList mkMode keymappings_raw)
+ + ''
+ end
+ set -g fish_key_bindings fish_my_key_bindings
+ '';
in {
options.soispha.programs.fish = {
enable = lib.mkEnableOption "fish";