{
  lib,
  config,
  ...
}: let
  cfg = config.marleyos.programs.git;
in {
  config = lib.mkIf cfg.enable {
    #     █████╗ ██╗     ██╗ █████╗ ███████╗███████╗███████╗
    #    ██╔══██╗██║     ██║██╔══██╗██╔════╝██╔════╝██╔════╝
    #    ███████║██║     ██║███████║███████╗█████╗  ███████╗
    #    ██╔══██║██║     ██║██╔══██║╚════██║██╔══╝  ╚════██║
    #    ██║  ██║███████╗██║██║  ██║███████║███████╗███████║
    #    ╚═╝  ╚═╝╚══════╝╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝

    programs.git.aliases = let
      fish_fns = config.programs.fish.functions;
    in {
      ### Staging ###

      a = "add";
      aa = "add --all";

      # Interactively stage parts of a file.
      apa = "add --patch";

      da = "diff";
      das = "diff --staged";
      daw = "diff --word-diff"; # Show diff by word.
      dasw = "diff --staged --word-diff";

      d = "!f() { git diff \"$@\" ':(exclude)package-lock.json' ':(exclude)*.lock'; }; f";
      ds = "!f() { git diff --staged \"$@\" ':(exclude)package-lock.json' ':(exclude)*.lock'; }; f";
      dw = "!f() { git diff --word-diff \"$@\" ':(exclude)package-lock.json' ':(exclude)*.lock'; }; f";
      dsw = "!f() { git diff --staged --word-diff \"$@\" ':(exclude)package-lock.json' ':(exclude)*.lock'; }; f";

      st = "status --short --branch";
      stu = "status --short --branch --untracked-files";
      stl = "status";

      ### Committing ###

      c = "commit";
      ce = "commit --amend";
      cen = "commit --amend --no-edit --no-verify";
      ca = "!git add --alll && git commit";
      cae = "!git add --all && git commit --amend";
      caen = "!git add --all && git commit --amend --no-edit --no-verify";
      cfu = "commit --fixup";

      rev = "revert";

      ### Working Dir & Index Manipulation ###

      co = "checkout";

      rt = "reset";

      rts = "reset --soft"; # undo commits & stage their changes

      rs = "restore --worktree"; # revert local changes
      rst = "restore --staged"; # unstage things
      rsa = "restore --worktree --staged";

      rss = "restore --worktree --source"; # specify a commit to revert to
      rsts = "restore --staged --source";
      rsas = "restore --worktree --staged --source";

      rmc = "rm --cached"; # leave worktree copy alone

      sta = "stash push";
      stam = "stash push --message";
      staa = "stash push --include-untracted";
      staam = "stash push --include-untracted --message";

      stap = "stash pop";
      stal = "stash list";
      stas = "stash show --text";

      cl = "clean -force"; # remove untracked & unignored files
      cldr = "clean --dry-run";

      ### Branches ###

      b = "branch";
      cb = "checkout -b";
      cm = lib.mkIf (fish_fns ? git_main_branch) "!git checkout $(git_main_branch)";
      cd = lib.mkIf (fish_fns ? git_develop_branch) "!git checkout $(git_develop_branch)";

      m = "merge";
      mtl = "mergetool --no-prompt";
      ma = "merge --abort";

      cp = "cherry-pick";
      cpa = "cherry-pick --abort";
      cpc = "cherry-pick --continue";
      cpq = "cherry-pick --quit";

      ### Remotes ###

      p = "push";
      pv = "push --verbose";
      pdr = "push --dry-run";
      pf = "push --force-with-lease --force-if-includes";
      pfv = "push --verbose --force-with-lease --force-if-includes";
      pff = "push --force";
      pffv = "push --verbose --force";

      f = "fetch";
      fa = "fetch --all --prune";

      pl = "pull";
      plr = "pull --rebase";

      sub = "submodule";
      subu = "submodule update --init --recursive";

      r = "remote";
      rv = "remote --verbose";
      ra = "remote add";
      rrm = "remote remove";
      rmv = "remote rename";
      rset = "remote set-url";
      rup = "remote update";

      ### Logs ###

      # Current branch.
      l = "log --pretty=lc --graph";
      lo = "log --pretty=lo --graph --date=human";
      ls = "log --pretty=lo --graph --date=human --simplify-by-decoration";
      lf = "log --pretty=lf --graph";
      ld = "log --pretty=lf --graph --cc --stat";
      lp = "log --pretty=lf --graph --cc --patch";

      lr = "log -5 --pretty=lc --graph";
      lro = "log -5 --pretty=lo --graph --date=human";
      lrs = "log -5 --pretty=lo --graph --date=human --simplify-by-decoration";
      lrf = "log -5 --pretty=lf --graph";
      lrd = "log -5 --pretty=lf --graph --cc --stat";
      lrp = "log -5 --pretty=lf --graph --cc --patch";

      # All branches on all remotes.
      la = "log --pretty=lc --graph --all";
      lao = "log --pretty=lo --graph --all --date=human";
      las = "log --pretty=lo --graph --all --date=human --simplify-by-decoration";
      laf = "log --pretty=lf --graph --all";
      lad = "log --pretty=lf --graph --all --cc --stat";
      lap = "log --pretty=lf --graph --all --cc --patch";

      lar = "log -5 --pretty=lc --graph --all";
      laro = "log -5 --pretty=lo --graph --all --date=human";
      lars = "log -5 --pretty=lo --graph --all --date=human --simplify-by-decoration";
      larf = "log -5 --pretty=lf --graph --all";
      lard = "log -5 --pretty=lf --graph --all --cc --stat";
      larp = "log -5 --pretty=lf --graph --all --cc --patch";

      ### Shortcuts ###

      nevermind = "!git reset --hard head && git clean -df";

      open = lib.mkIf (config.programs.fish.enable && (fish_fns ? git_open)) "!fish -c git_open";

      chash = "!git log --oneline | gum filter --height 10 | cut -d' ' -f1 | ${config.marleyos.apps.clipboard.copy-command} &>/dev/null";
    };
  };
}