fish functions and user key bindings

This commit is contained in:
Noah Masur
2025-02-02 21:45:34 -05:00
parent 1226eafef2
commit 6f2b2a7694
24 changed files with 274 additions and 335 deletions

View File

@ -10,34 +10,35 @@ in
{
options.nmasur.presets.programs.fish.enable = lib.mkEnableOption "Fish shell";
options.nmasur.presets.programs.fish = {
enable = lib.mkEnableOption "Fish shell";
fish_user_key_bindings = lib.mkOption {
type = lib.types.lines;
description = "Text of fish_user_key_bindings function";
default = "";
};
};
config = lib.mkIf cfg.enable {
cfg.fish_user_key_bindings = # fish
''
# Shift-Enter (defined by terminal)
bind -M insert \x1F accept-autosuggestion
bind -M default \x1F accept-autosuggestion
'';
programs.fish = {
enable = true;
functions = {
commandline-git-commits = {
description = "Insert commit into commandline";
body = builtins.readFile ./functions/commandline-git-commits.fish;
};
copy = {
description = "Copy file contents into clipboard";
body = "cat $argv | pbcopy"; # Need to fix for non-macOS
};
edit = {
description = "Open a file in Vim";
body = builtins.readFile ./functions/edit.fish;
};
envs = {
description = "Evaluate a bash-like environment variables file";
body = ''set -gx (cat $argv | tr "=" " " | string split ' ')'';
};
fcd = {
description = "Jump to directory";
argumentNames = "directory";
body = builtins.readFile ./functions/fcd.fish;
};
fish_user_key_bindings = {
body = builtins.readFile ./functions/fish_user_key_bindings.fish;
};
@ -48,14 +49,6 @@ in
description = "Tidy up JSON using jq";
body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS
};
recent = {
description = "Open a recent file in Vim";
body = builtins.readFile ./functions/recent.fish;
};
search-and-edit = {
description = "Search and open the relevant file in Vim";
body = builtins.readFile ./functions/search-and-edit.fish;
};
_which = {
description = "Identify the path to a program in the shell";
body = "command --search (string sub --start=2 $argv)";
@ -123,9 +116,5 @@ in
home.sessionVariables.fish_greeting = "";
programs.starship.enableFishIntegration = true;
programs.zoxide.enableFishIntegration = true;
programs.fzf.enableFishIntegration = true;
};
}