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

88 lines
2.2 KiB
Nix

{
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";
hasNeovim = config.programs.neovim.enable;
hasLazygit = config.programs.lazygit.enable;
hasLazydocker = hasPackage "lazydocker";
hasNixYourShell = hasPackage "nix-your-shell";
hasShellColor = config.programs.shellcolor.enable;
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;
}
];
shellAliases = {
lzg = mkIf hasLazygit "lazygit";
lzd = mkIf hasLazydocker "lazydocker";
batt = ''upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -e "percentage" -e "state"'';
hx = "~/Documents/heliox-cli/target/debug/heliox-cli --mode";
slp = "systemctl suspend";
sdn = "shutdown 0";
};
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";
nr = "nixos-rebuild --flake .";
nrs = "nixos-rebuild --flake . switch";
snr = "sudo nixos-rebuild --flake .";
snrs = "sudo nixos-rebuild --flake . switch";
hm = "home-manager --flake .";
hms = "home-manager --flake . switch";
ls = mkIf hasExa "eza";
exa = mkIf hasExa "eza";
vim = mkIf hasNeovim "nvim";
vi = vim;
v = vim;
};
functions = {
# Disable greeting
fish_greeting = "";
};
};
home.packages = with pkgs; [grc fzf nix-your-shell];
}