git: Make aliases agnostic of default branch name

This commit is contained in:
Simon Bruder 2021-09-06 16:30:14 +02:00
parent d840d4c227
commit d46eca0ab0
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -54,31 +54,35 @@
}; };
}; };
programs.zsh.shellAliases = { programs.zsh.shellAliases =
ga = "git add"; let
gap = "git add --patch"; defaultBranch = "\${\${\$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)##refs/remotes/origin/}:-master}";
gc = "git commit"; in
gco = "git checkout"; {
gcp = "git cherry-pick"; ga = "git add";
gcv = "git commit --verbose"; gap = "git add --patch";
gd = "git diff"; gc = "git commit";
gdc = "git diff --cached"; gco = "git checkout";
gfom = "git fetch origin master"; gcp = "git cherry-pick";
gl = "git log"; gcv = "git commit --verbose";
glp = "git log --patch"; gd = "git diff";
gls = "git log --stat"; gdc = "git diff --cached";
gp = "git push"; gfom = "git fetch origin ${defaultBranch}";
grb = "git rebase"; gl = "git log";
grbi = "git rebase -i"; glp = "git log --patch";
grbias = "git rebase -i --autosquash"; gls = "git log --stat";
grbim = "git rebase -i master"; gp = "git push";
grbm = "git rebase master"; grb = "git rebase";
grbom = "git rebase origin/master"; grbi = "git rebase -i";
grs = "git restore"; grbias = "git rebase -i --autosquash";
grss = "git restore --staged"; grbim = "git rebase -i ${defaultBranch}";
gs = "git switch"; grbm = "git rebase ${defaultBranch}";
gsc = "git switch -c"; grbom = "git rebase origin/${defaultBranch}";
gsm = "git switch master"; grs = "git restore";
gst = "git status"; grss = "git restore --staged";
}; gs = "git switch";
gsc = "git switch -c";
gsm = "git switch ${defaultBranch}";
gst = "git status";
};
} }