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