1 { pkgs, lib, config, ... }:
3 home.packages = lib.mkIf config.programs.git.enable [
20 enable = lib.mkDefault true;
21 ignores = [ "*~" "*.swp" ];
22 package = lib.mkDefault pkgs.gitMinimal;
29 authors = "shortlog -s -n";
31 bl = "git log -p -M --follow --stat --";
33 ca = "commit --amend";
34 caa = "commit --amend -C@";
35 caaa = "commit --amend -C@ -a";
36 cf = "commit --fixup";
40 dcw = "diff --cached --word-diff=color";
41 dh = "diff --histogram";
42 dp = "diff --patience";
43 dt = "difftool --patience";
44 dtc = "difftool --cached";
45 dw = "diff --word-diff=color";
47 ign = "ls-files -o -i --exclude-standard";
49 ll = "log --graph --decorate --pretty=oneline --abbrev-commit";
50 lp = "log -p --pretty=fuller";
51 lpg = "log -p --pretty=fuller -g";
54 patch = "push rad HEAD:refs/patches";
62 spull = "!git-svn fetch && git-svn rebase";
63 spush = "!git-svn dcommit";
67 fetch-local = "!git fetch local && git tag -d $(git describe --exact-match 2>/dev/null >/dev/null) && git fetch --tags local";
68 pull-local = "!git fetch-local && git checkout -B master local/master";
69 pull-local-old = "!git fetch-local && git checkout HEAD'^' && git branch -f master local/master && git checkout master";
70 root = ''!git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"'';
71 has-tag-version = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]\\(\\^{}\\)\\?\"'';
72 tag-version = ''"!git has-tag-version && return; v=$(TZ=UTC date +v%Y-%m-%d) && name=$(git rev-parse --show-toplevel | sed -e 's:^.*/work::') && set -x && git tag -s -m \"$name $v\" $v"'';
73 has-tag-majordate = ''!git show-ref --tags -d | grep -qx \"^$(git rev-parse HEAD) refs/tags/v[0-9]\\+.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\(\\^{}\\)\\?\"'';
74 tag-majordate = ''"!git has-tag-majordate && return; name=$(basename $(dirname $(git rev-parse --show-toplevel))); major=$(basename $(git rev-parse --show-toplevel)); version=''${version:-$(TZ=UTC date +\"v$major.%Y%m%d\")} && set -x && git tag -s -m \"$name $version\" $version"'';
75 tag-cabal = ''"!set -x; for cabal in $(git ls-files | grep '.*\\.cabal$'); do name=$(sed -ne 's/^name: *\\(.*\\)/\\1/p' \"$cabal\"); version=$(sed -ne 's/^version: *\\(.*\\)/\\1/p' \"$cabal\"); git tag --merged | grep -Fqx \"$name-$version\" || git tag -f -s -m \"$name v$version\" $name-$version; done"'';
76 cl = "notes --ref=changelog append";
77 cl-bug = "notes --ref=changelogs/bugs append";
78 cl-feature = "notes --ref=changelogs/features append";
79 wip = "for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads";
82 browser.elinks.cmd = "elinks";
83 color.branch = "auto";
85 #color.diff.whitespace = "red reverse";
86 color.status = "auto";
87 core.commentChar = "auto";
88 core.quotepath = "false";
89 core.whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
90 diff.algorithm = "histogram";
91 diff.sqldiff.command = "sqldiff";
92 format.pretty = "oneline";
93 gui.fontdiff = ''-family "DejaVu Sans Mono" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
94 gui.fontui = ''-family "DejaVu Sans" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
95 gui.spellingdictionary = "en_US";
97 guitool."Rebase interactive" = {
98 cmd = "EDITOR=gvim git rebase -i $REVISION";
101 init.defaultBranch = "main";
102 merge.tool = "vimdiff";
103 merge.conflictStyle = "zdiff3";
104 protocol.version = 2;
106 push.default = "simple";
107 rebase.autosquash = "true";
108 sendemail.chainReplyTo = "false";
109 sendemail.composeencoding = "UTF-8";
110 sendemail.confirm = "always";
111 sendemail.envelopeSender = "auto";
112 sendemail.multiedit = "yes";
113 sendemail.suppressFrom = "false";
114 sendemail.suppresscc = "self";
115 sendemail.thread = "true";
116 sendemail.validate = "true";
117 web.browser = "elinks";
121 diff.external = lib.concatStringsSep " " [
122 "${pkgs.difftastic}/bin/difft"
125 "--display side-by-side"
130 diff.tool = "difftastic";
131 difftool.prompt = false;
132 difftool.difftastic.cmd = ''${pkgs.difftastic}/bin/difft "$LOCAL" "$REMOTE"'';
133 pager.difftool = true;
138 core.pager = "delta --grep-separator-symbol keep";
139 interactive.diffFilter = "delta --color-only --features=interactive";
140 delta.features = "decorations";
141 delta.interactive = {
142 keep-plus-minus-markers = false;
144 delta.decorations = {
145 commit-decoration-style = "blue ol";
146 commit-style = "raw";
148 hunk-header-decoration-style = "blue box";
149 hunk-header-file-style = "red";
150 hunk-header-line-number-style = "#067a00";
151 hunk-header-style = "file line-number syntax";
156 programs.bash = lib.mkIf config.programs.git.enable {
159 ge = "git-edit-commit";
161 gge = "git-grep-edit";
165 git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
166 git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }