nixos/modules/base/fish.nix

62 lines
2.1 KiB
Nix
Raw Permalink Normal View History

2024-03-05 22:57:41 +01:00
{pkgs, ...}: {
2023-08-25 00:57:42 +02:00
# Fish is a Unix shell with a focus on interactivity and usability. Fish is
# designed to give the user features by default, rather than by
# configuration.
2024-06-27 20:37:34 +02:00
# https://wiki.nixos.org/wiki/Fish
# https://wiki.nixos.org/wiki/Command_Shell
2023-08-01 15:35:09 +02:00
programs.fish = {
enable = true;
interactiveShellInit = ''
2024-05-25 03:27:23 +02:00
# Allow jumping between prompts (ctrl+shift+z/x) in foot.
# https://codeberg.org/dnkl/foot/wiki#jumping-between-prompts
function mark_prompt_start --on-event fish_prompt
echo -en "\e]133;A\e\\"
end
2024-05-22 17:54:10 +02:00
2024-05-25 03:27:23 +02:00
# Allow piping last command's output (ctrl+shift+g) in foot.
# https://codeberg.org/dnkl/foot/wiki#piping-last-command-s-output
function foot_cmd_start --on-event fish_preexec
echo -en "\e]133;C\e\\"
end
function foot_cmd_end --on-event fish_postexec
echo -en "\e]133;D\e\\"
end
# Allows 's foo bar' for 'nix shell nixpkgs#foo nixpkgs#bar'
2024-05-22 17:54:10 +02:00
function s --wraps 'nix shell'
nix shell nixpkgs#$argv
end
2024-05-25 03:27:23 +02:00
2024-07-06 23:10:56 +02:00
# fzf: use ctrl+f to list files
fzf_configure_bindings --directory=\cf
2023-08-01 15:35:09 +02:00
'';
};
2023-08-14 00:40:49 +02:00
# Installing a fish plugin automatically enables it
environment.systemPackages = with pkgs; [
fishPlugins.colored-man-pages
fishPlugins.fzf-fish
fishPlugins.pure
];
# Set fish as the default shell system-wide
2023-08-01 15:35:09 +02:00
users.defaultUserShell = pkgs.fish;
2023-08-14 00:40:49 +02:00
# Add fish to the list of permissible login shells for user accounts
2024-03-05 22:57:41 +01:00
environment.shells = with pkgs; [fish];
2023-08-14 00:40:49 +02:00
2023-08-25 00:57:42 +02:00
# Enabling fish in both NixOS and home manager is required to pick up
# completions and environment variables set by NixOS nixpkgs _and_ home
# manager modules at the same time. As a test, the environment variables from
2023-08-14 00:40:49 +02:00
# $ nix repl
# > :lf .
# > :p nixosConfigurations.omega.config.home-manager.users.caspervk.home.sessionVariables
# > :p nixosConfigurations.omega.config.home-manager.users.caspervk.home.sessionVariablesExtra
2023-08-25 00:57:42 +02:00
# should be available in the desktop environment's shell. See
# https://nix-community.github.io/home-manager/index.html#_why_are_the_session_variables_not_set.
2023-08-14 00:40:49 +02:00
home-manager.users.caspervk = {
programs.fish.enable = true;
};
2023-08-01 15:35:09 +02:00
}