fish: add binds option (#7121)

binds options is a wrapper of fish_user_key_bindings that contains
custom binds
This commit is contained in:
Mohamad Fikri 2025-05-29 10:35:08 +07:00 committed by GitHub
parent 13ed57aaa6
commit 85a27991d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 155 additions and 0 deletions

View file

@ -0,0 +1,46 @@
{ lib, ... }:
{
config = {
programs.fish = {
enable = true;
binds = {
"ctrl-d".command = "exit";
"ctrl-c" = {
mode = "insert";
command = [
"kill-whole-line"
"repaint"
];
};
"ctrl-g" = {
command = [
"git diff"
"repaint"
];
};
};
};
# Needed to avoid error with dummy fish package.
xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (
builtins.toFile "empty" ""
);
nmt = {
description = "if fish.binds is set, check function exists and contains valid binds";
script = ''
assertFileExists home-files/.config/fish/functions/fish_user_key_bindings.fish
assertFileContains home-files/.config/fish/functions/fish_user_key_bindings.fish \
"bind ctrl-d exit"
assertFileContains home-files/.config/fish/functions/fish_user_key_bindings.fish \
"bind --mode insert ctrl-c kill-whole-line repaint"
assertFileContains home-files/.config/fish/functions/fish_user_key_bindings.fish \
"bind ctrl-g 'git diff' repaint"
'';
};
};
}

View file

@ -5,4 +5,5 @@
fish-no-functions = ./no-functions.nix;
fish-plugins = ./plugins.nix;
fish-manpage = ./manpage.nix;
fish-binds = ./binds.nix;
}