{
  pkgs,
  lib,
  config,
  ...
}:

let
  inherit (lib) concatStringsSep mkOption types;

  mkFzfOptionsString = lines: concatStringsSep " " lines;

  catppuccinFzfOptions = {
    mocha = mkFzfOptionsString [
      "--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8"
      "--color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc"
      "--color=marker:#b4befe,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
      "--color=selected-bg:#45475a"
      "--multi"
    ];
    latte = mkFzfOptionsString [
      "--color=bg+:#ccd0da,bg:#eff1f5,spinner:#dc8a78,hl:#d20f39"
      "--color=fg:#4c4f69,header:#d20f39,info:#1e66f5,pointer:#dc8a78"
      "--color=marker:#fe640b,fg+:#4c4f69,prompt:#1e66f5,hl+:#d20f39"
      "--color=selected-bg:#acb0be"
      "--multi"
    ];
  };
in
{
  options.fish = {
    theme = mkOption {
      type = types.enum (builtins.attrNames catppuccinFzfOptions);
      default = "mocha";
      description = "Catppuccin theme variant used for Fish integrations such as FZF.";
      example = "latte";
    };
  };

  config = {
    programs.fish = {
      enable = true;
      plugins = [
        {
          name = "z";
          src = pkgs.fetchFromGitHub {
            owner = "jethrokuan";
            repo = "z";
            rev = "e0e1b9dfdba362f8ab1ae8c1afc7ccf62b89f7eb";
            sha256 = "0dbnir6jbwjpjalz14snzd3cgdysgcs3raznsijd6savad3qhijc";
          };
        }
        {
          name = "autopair";
          src = pkgs.fishPlugins.autopair.src;
        }
        {
          name = "foreign-env";
          src = pkgs.fishPlugins.foreign-env.src;
        }
        {
          name = "fzf";
          src = pkgs.fishPlugins.fzf.src;
        }
        {
          name = "done";
          src = pkgs.fishPlugins.done.src;
        }
        {
          name = "grc";
          src = pkgs.fishPlugins.grc.src;
        }
      ];
      shellAbbrs = {
        ls = "eza -l";
        lg = "lazygit";
        ka = "kubectl apply -f";
        e = "nvim";
      };
      interactiveShellInit =
        let
          fzfOpts = catppuccinFzfOptions.${config.fish.theme};
        in
        ''
                              fish_vi_key_bindings
                              set fish_greeting
                              set FLAKE_DIR "/home/fw/nix"
                              if test -r /run/secrets/jira_token
                                set -gx JIRA_API_TOKEN (string trim (cat /run/secrets/jira_token))
                              end
                              set -gx GITHUB_PERSONAL_ACCESS_TOKEN (cat /run/secrets/github_token)
                              set -gx GITHUB_HOST "https://github.com"
                              set -gx GRAFANA_SERVICE_ACCOUNT_TOKEN (cat /run/secrets/grafana_token)
                              set -gx GRAFANA_URL "https://monitoring.internalifacts.se"
                              set -Ux FZF_CTRL_R_OPTS "--reverse"
                              set -Ux FZF_TMUX_OPTS "-p"
                              set -e GOROOT
                    		  set -x -U GOPATH $HOME/.go
                              gh completion -s fish > ~/.config/fish/completions/gh.fish
                              set -gx PATH $PATH $HOME/scripts
                              set -gx PATH $PATH $HOME/.krew/bin


                              if not set -q SSH_AUTH_SOCK
                                eval (ssh-agent -c)
                                ssh-add ~/.ssh/id_ed25519 >/dev/null 2>&1
          						set SSH_AUTH_SOCK /home/fw/.bitwarden-ssh-agent.sock
                              end

                              set -Ux FZF_DEFAULT_OPTS "${fzfOpts}"
        '';
    };
  };
}
