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";
60 spull = "!git-svn fetch && git-svn rebase";
61 spush = "!git-svn dcommit";
65 fetch-local = "!git fetch local && git tag -d $(git describe --exact-match 2>/dev/null >/dev/null) && git fetch --tags local";
66 pull-local = "!git fetch-local && git checkout -B master local/master";
67 pull-local-old = "!git fetch-local && git checkout HEAD'^' && git branch -f master local/master && git checkout master";
68 root = ''!git rev-list --parents HEAD | egrep "^[a-f0-9]{40}$"'';
69 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]\\(\\^{}\\)\\?\"'';
70 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"'';
71 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]\\(\\^{}\\)\\?\"'';
72 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"'';
73 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"'';
74 cl = "notes --ref=changelog append";
75 cl-bug = "notes --ref=changelogs/bugs append";
76 cl-feature = "notes --ref=changelogs/features append";
77 wip = "for-each-ref --sort='authordate:iso8601' --format=' %(color:green)%(authordate:relative)%09%(color:white)%(refname:short)' refs/heads";
80 browser.elinks.cmd = "elinks";
81 color.branch = "auto";
83 #color.diff.whitespace = "red reverse";
84 color.status = "auto";
85 core.commentChar = "auto";
86 core.quotepath = "false";
87 core.whitespace = "fix,-indent-with-non-tab,trailing-space,cr-at-eol";
88 diff.algorithm = "histogram";
89 diff.sqldiff.command = "sqldiff";
90 format.pretty = "oneline";
91 gui.fontdiff = ''-family "DejaVu Sans Mono" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
92 gui.fontui = ''-family "DejaVu Sans" -size 8 -weight normal -slant roman -underline 0 -overstrike 0'';
93 gui.spellingdictionary = "en_US";
95 guitool."Rebase interactive" = {
96 cmd = "EDITOR=gvim git rebase -i $REVISION";
99 init.defaultBranch = "main";
100 merge.tool = "vimdiff";
101 merge.conflictStyle = "zdiff3";
102 protocol.version = 2;
104 push.default = "simple";
105 rebase.autosquash = "true";
106 sendemail.chainReplyTo = "false";
107 sendemail.composeencoding = "UTF-8";
108 sendemail.confirm = "always";
109 sendemail.envelopeSender = "auto";
110 sendemail.multiedit = "yes";
111 sendemail.suppressFrom = "false";
112 sendemail.suppresscc = "self";
113 sendemail.thread = "true";
114 sendemail.validate = "true";
115 web.browser = "elinks";
119 diff.external = lib.concatStringsSep " " [
120 "${pkgs.difftastic}/bin/difft"
123 "--display side-by-side"
128 diff.tool = "difftastic";
129 difftool.prompt = false;
130 difftool.difftastic.cmd = ''${pkgs.difftastic}/bin/difft "$LOCAL" "$REMOTE"'';
131 pager.difftool = true;
136 core.pager = "delta";
137 interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only --features=interactive";
138 delta.features = "decorations";
139 delta.interactive = {
140 keep-plus-minus-markers = false;
142 delta.decorations = {
143 commit-decoration-style = "blue ol";
144 commit-style = "raw";
146 hunk-header-decoration-style = "blue box";
147 hunk-header-file-style = "red";
148 hunk-header-line-number-style = "#067a00";
149 hunk-header-style = "file line-number syntax";
154 programs.bash = lib.mkIf config.programs.git.enable {
157 ge = "git-edit-commit";
159 gge = "git-grep-edit";
163 git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
164 git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }