Skip to content

Commit 2c06c4d

Browse files
committed
Fix git config
1 parent c78bc02 commit 2c06c4d

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

modules/profiles/home/git/common.nix

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,51 @@
44
programs.git = {
55
enable = true;
66

7-
settings = {
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+
'';
29+
in {
830
user.name = "Ethan Turkeltaub";
931

10-
alias = let
11-
gitCommand = lib.getExe config.programs.git.package;
12-
fzfCommand = lib.getExe pkgs.fzf;
13-
ghCommand = lib.getExe pkgs.gh;
14-
superprune = pkgs.writeShellScript "git-alias-superprune" ''
15-
echo 'Fetching remote then deleting branches that are gone. This may take a moment'
16-
17-
${gitCommand} fetch -p
18-
19-
gone=$(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}')
20-
for branch in $gone; do
21-
${gitCommand} branch -D $branch;
22-
done;
23-
'';
24-
co = pkgs.writeShellScript "git-alias-co" ''
25-
${gitCommand} checkout "$(${gitCommand} branch --sort="-committerdate" | ${fzfCommand} | tr -d '[:space:]')";
26-
'';
27-
wipe = pkgs.writeShellScript "git-alias-wipe" ''
28-
${gitCommand} add .
29-
${gitCommand} stash
30-
'';
31-
in {
32+
alias = {
3233
s = "status";
3334
superprune = "!sh ${superprune}";
3435
co = "!sh ${co}";
3536
wipe = "!sh ${wipe}";
36-
sync = "!${ghCommand} repo sync";
37+
sync = "!${gh} repo sync";
3738
};
3839

39-
extraConfig = let deltaCommand = lib.getExe pkgs.delta;
40-
in {
41-
core.pager = deltaCommand;
42-
interactive.diffFilter = "${deltaCommand} --color-only";
43-
http = { sslCAinfo = "/etc/ssl/certs/ca-certificates.crt"; };
44-
color = {
45-
status = "always";
46-
diff = "always";
47-
};
48-
init.defaultBranch = "main";
40+
core.pager = delta;
41+
42+
interactive.diffFilter = "${delta} --color-only";
43+
44+
http = { sslCAinfo = "/etc/ssl/certs/ca-certificates.crt"; };
45+
46+
color = {
47+
status = "always";
48+
diff = "always";
4949
};
50+
51+
init.defaultBranch = "main";
5052
};
5153

5254
ignores = [ "*~" "#*#" ".elc" ".#*" "flycheck_*.el" ".projectile" ];

0 commit comments

Comments
 (0)