|
4 | 4 | programs.git = { |
5 | 5 | enable = true; |
6 | 6 |
|
7 | | - settings = let |
8 | | - delta = lib.getExe pkgs.delta; |
9 | | - git = lib.getExe config.programs.git.package; |
10 | | - fzf = lib.getExe pkgs.fzf; |
11 | | - gh = lib.getExe pkgs.gh; |
12 | | - superprune = pkgs.writeShellScript "git-alias-superprune" '' |
13 | | - echo 'Fetching remote then deleting branches that are gone. This may take a moment' |
14 | | -
|
15 | | - ${git} fetch -p |
16 | | -
|
17 | | - gone=$(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}') |
18 | | - for branch in $gone; do |
19 | | - ${git} branch -D $branch; |
20 | | - done; |
21 | | - ''; |
22 | | - co = pkgs.writeShellScript "git-alias-co" '' |
23 | | - ${git} checkout "$(${git} branch --sort="-committerdate" | ${fzf} | tr -d '[:space:]')"; |
24 | | - ''; |
25 | | - wipe = pkgs.writeShellScript "git-alias-wipe" '' |
26 | | - ${git} add . |
27 | | - ${git} stash |
28 | | - ''; |
| 7 | + settings = let delta = lib.getExe pkgs.delta; |
29 | 8 | in { |
30 | 9 | user.name = "Ethan Turkeltaub"; |
31 | 10 |
|
32 | | - alias = { |
| 11 | + alias = let |
| 12 | + gh = lib.getExe pkgs.gh; |
| 13 | + mkGitShellScript = { name, text, extraRuntimeInputs ? [ ] }: |
| 14 | + lib.getExe (pkgs.writeShellApplication { |
| 15 | + inherit name text; |
| 16 | + |
| 17 | + runtimeInputs = [ config.programs.git.package ] |
| 18 | + ++ extraRuntimeInputs; |
| 19 | + }); |
| 20 | + superprune = mkGitShellScript { |
| 21 | + name = "git-alias-superprune"; |
| 22 | + text = '' |
| 23 | + echo 'Fetching remote then deleting branches that are gone. This may take a moment' |
| 24 | +
|
| 25 | + git fetch -p |
| 26 | +
|
| 27 | + gone=$(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}') |
| 28 | + for branch in $gone; do |
| 29 | + git branch -D "$branch"; |
| 30 | + done; |
| 31 | + ''; |
| 32 | + }; |
| 33 | + co = mkGitShellScript { |
| 34 | + name = "git-alias-co"; |
| 35 | + extraRuntimeInputs = [ pkgs.fzf ]; |
| 36 | + text = '' |
| 37 | + git checkout "$(git branch --sort="-committerdate" | fzf | tr -d '[:space:]')"; |
| 38 | + ''; |
| 39 | + }; |
| 40 | + wipe = mkGitShellScript { |
| 41 | + name = "git-alias-wipe"; |
| 42 | + text = '' |
| 43 | + git add . |
| 44 | + git stash |
| 45 | + ''; |
| 46 | + }; |
| 47 | + in { |
33 | 48 | s = "status"; |
34 | 49 | superprune = "!sh ${superprune}"; |
35 | 50 | co = "!sh ${co}"; |
|
0 commit comments