nix-config/home/features/cli/fish.nix

107 lines
3 KiB
Nix
Raw Normal View History

2023-12-26 13:59:30 +01:00
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
hasPackage = pname: lib.any (p: p ? pname && p.pname == pname) config.home.packages;
hasRipgrep = hasPackage "ripgrep";
hasExa = hasPackage "eza";
hasLazygit = config.programs.lazygit.enable;
hasLazydocker = hasPackage "lazydocker";
hasNixYourShell = hasPackage "nix-your-shell";
hasShellColor = config.programs.shellcolor.enable;
2024-01-07 15:37:01 +01:00
hasWezterm = config.programs.wezterm.enable;
2023-12-26 13:59:30 +01:00
shellcolor = "${pkgs.shellcolord}/bin/shellcolor";
in {
programs.fish = {
enable = true;
interactiveShellInit = ''
${
if hasNixYourShell
then "nix-your-shell fish | source"
else ""
}
'';
plugins = [
{
name = "grc";
src = pkgs.fishPlugins.grc.src;
}
{
name = "fzf";
src = pkgs.fishPlugins.fzf.src;
}
{
name = "tide";
src = pkgs.fishPlugins.tide.src;
}
{
name = "sponge";
src = pkgs.fishPlugins.sponge.src;
}
{
name = "autopair";
src = pkgs.fishPlugins.autopair.src;
}
2024-01-07 15:36:16 +01:00
{
name = "puffer";
src = pkgs.fishPlugins.puffer.src;
}
{
name = "z";
src = pkgs.fishPlugins.z.src;
}
2023-12-26 13:59:30 +01:00
];
shellAliases = {
lzg = mkIf hasLazygit "lazygit";
lzd = mkIf hasLazydocker "lazydocker";
batt = ''upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -e "percentage" -e "state"'';
2024-02-04 20:53:09 +01:00
hx = "heliox-cli --mode";
2023-12-26 13:59:30 +01:00
slp = "systemctl suspend";
sdn = "shutdown 0";
nrs = "nh os switch ~/.setup";
2024-01-07 15:37:01 +01:00
ls = mkIf hasExa "eza";
ll = mkIf hasExa "eza -l";
la = mkIf hasExa "eza -la";
exa = mkIf hasExa "eza";
imgcat = mkIf hasWezterm "wezterm imgcat";
2023-12-26 13:59:30 +01:00
};
shellAbbrs = rec {
jqless = "jq -C | less -r";
n = "nix";
nd = "nix develop -c $SHELL";
ns = "nix shell";
nsn = "nix shell nixpkgs#";
nb = "nix build";
nbn = "nix build nixpkgs#";
nf = "nix flake";
2024-01-07 15:37:01 +01:00
glk = "gpg --list-keys --with-keygrip";
gssh = "gpg --export-ssh-key";
gnk = "gpg --full-generate-key --expert";
gek = "gpg --edit-key --expert";
udmount = "udisksctl mount -b";
udumount = "udisksctl unmount -b";
2023-12-26 13:59:30 +01:00
};
functions = {
# Disable greeting
fish_greeting = "";
fish_init_custom = ''
tide configure --auto --style=Rainbow --prompt_colors='True color' --show_time=No --rainbow_prompt_separators=Vertical --powerline_prompt_heads=Slanted --powerline_prompt_tails=Flat --powerline_prompt_style='Two lines, frame' --prompt_connection=Solid --powerline_right_prompt_frame=No --prompt_connection_andor_frame_color=Darkest --prompt_spacing=Compact --icons='Many icons' --transient=Yes
'';
2023-12-26 13:59:30 +01:00
};
};
home.packages = with pkgs; [grc fzf nix-your-shell];
# Applies tide configure on rebuild
home.activation.configureTide = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.fish}/bin/fish -c "fish_init_custom"
'';
2023-12-26 13:59:30 +01:00
}