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