{ pkgs, lib, ... }:
let
  inherit (lib.my) getExe';
in
{
  programs.fish = {
    enable = true;
    shellAbbrs = {
      clip = "wl-copy";
    };
    functions = {
      gitignore = # fish
        "curl -sL https://www.gitignore.io/api/$argv";
      mv-bad-creation-date = # fish
        ''
          ${getExe' pkgs.exiftool "exiftool"} -if 'not $CreateDate' -p '$FileName' "$PWD/$argv[1]" | xargs -I {} mv -i "$PWD/$argv[1]/{}" "$argv[2]"
        '';
      rename-images = # fish
        ''
          set -f input "$PWD/$argv[1]"

          if not test -d $input
              echo "input is not a directory"
          else
              ${getExe' pkgs.exiftool "exiftool"} -if '$CreateDate' -p '$FileName' "$input" | xargs -I {} jhead -n%Y-%m-%d-%H%M%S "$input/{}"
          end
        '';
      fish_prompt = builtins.readFile ./fish_prompt.fish;
      revert = # fish
        ''
          env --chdir $HOME/.nixconf sudo nixos-rebuild switch --flake .#$(hostname) --rollback
        '';
    };
  };
}
