1
Fork 0
satellite/home/features/cli/fish/default.nix

91 lines
2.4 KiB
Nix
Raw Permalink Normal View History

{
pkgs,
config,
lib,
...
}:
2024-02-09 20:15:32 +01:00
let
repaint = "commandline -f repaint";
fishKeybinds = {
# C-x to clear screen
"\\cx" = "clear && ${repaint}";
# C-z to return to background process
"\\cz" = "fg && ${repaint}";
# C-y to yank current command
"\\cy" = "wl-copy \$(commandline)";
# C-e to launch $EDITOR
"\\ce" = "$EDITOR";
# C-S-e to edit commandline using $EDITOR
"\\e\\[69\\;5u" = "edit_command_buffer";
# C-enter to run command through a pager
"\\e\\[13\\;2u" = "commandline -a ' | $PAGER' && commandline -f execute";
# C-g to open lazygit
"\\cg" = "lazygit";
2024-07-06 19:32:14 +02:00
# C-S-f to open mini.files
"\\e\\[70\\;5u" = ''nvim +":lua require('mini.files').open()"'';
2024-02-09 20:15:32 +01:00
};
mkKeybind =
key: value:
let
escaped = lib.escapeShellArg value;
2024-02-09 20:15:32 +01:00
in
''
bind -M default ${key} ${escaped}
bind -M insert ${key} ${escaped}
'';
in
2023-02-10 00:11:54 +01:00
{
# {{{ Fzf
2023-12-07 22:35:57 +01:00
programs.fzf = {
enable = true;
defaultOptions = [ "--no-scrollbar" ];
changeDirWidgetOptions = [ "--preview '${lib.getExe pkgs.eza} --icons --tree --color=always {}'" ];
2023-12-07 22:35:57 +01:00
fileWidgetOptions = [ "--preview '${lib.getExe pkgs.bat} --number --color=always {}'" ];
2023-12-07 22:35:57 +01:00
};
stylix.targets.fzf.enable = true;
# }}}
# {{{ Fish
2023-02-10 00:11:54 +01:00
programs.fish = {
enable = true;
interactiveShellInit = ''
2024-02-09 20:15:32 +01:00
# ❄️ Fish keybinds generated using nix ^~^
function fish_nix_key_bindings
${lib.concatStringsSep "\n" (lib.mapAttrsToList mkKeybind fishKeybinds)}
end
${builtins.readFile ./config.fish}
# Modify nix-shell to use `fish` as it's default shell
${lib.getExe pkgs.nix-your-shell} fish | source
'';
2023-02-10 00:11:54 +01:00
# {{{ Plugins
2023-12-02 00:46:56 +01:00
plugins =
let
plugins = with pkgs.fishPlugins; [
z # Jump to directories by typing "z <directory-name>"
done # Trigger a notification when long commands finish execution
puffer # Text expansion (i.e. expanding .... to ../../../)
sponge # Remove failed commands and whatnot from history
colored-man-pages
2023-12-02 00:46:56 +01:00
];
in
# For some reason home-manager expects a slightly different format 🤔
lib.forEach plugins (plugin: {
name = plugin.pname;
inherit (plugin) src;
});
2023-12-07 22:35:57 +01:00
# }}}
2023-02-10 00:11:54 +01:00
};
2023-11-04 20:18:14 +01:00
satellite.persistence.at.state.apps.fish.directories = [
"${config.xdg.dataHome}/fish"
"${config.xdg.dataHome}/z" # The z fish plugin requires this
2023-11-04 20:18:14 +01:00
];
2023-12-07 22:35:57 +01:00
# }}}
2023-02-10 00:11:54 +01:00
}