nix/home/terminal/fish/default.nix
2025-11-22 13:16:23 -05:00

40 lines
1,022 B
Nix

{ config, pkgs, ... }:
{
programs.fish = {
enable = true;
functions = {
fish_prompt = {
description = "Write out the prompt";
body = ''
set -l last_status $status
set -l nix_shell_info (
if test -n "$IN_NIX_SHELL"
echo -n "<nix-shell> "
end
)
set -l user_host (set_color $fish_color_user)"$USER"(set_color normal)"@"(set_color $fish_color_host)(prompt_hostname)(set_color normal)
set -l cwd (set_color $fish_color_cwd)(prompt_pwd)(set_color normal)
set -l git_info (fish_git_prompt)
echo -n -s "$user_host" " " "$nix_shell_info" "$cwd" "$git_info" "> "
'';
};
nix-shell = {
description = "Wrapper for nix-shell that runs fish by default";
body = ''
if test (count $argv) -eq 0
command nix-shell --run fish
else
command nix-shell --run fish $argv
end
'';
};
};
};
}