diff --git a/users/jalr/modules/fish.nix b/users/jalr/modules/fish.nix index f9c2cf2..570509a 100644 --- a/users/jalr/modules/fish.nix +++ b/users/jalr/modules/fish.nix @@ -98,6 +98,10 @@ # fix too dark color on solarized theme set -g fish_color_autosuggestion brgreen + + if type -q fish_set_git_author_by_pwd + fish_set_git_author_by_pwd + end ''; functions = { diff --git a/users/jalr/modules/git.nix b/users/jalr/modules/git.nix index 1090f43..9d4391f 100644 --- a/users/jalr/modules/git.nix +++ b/users/jalr/modules/git.nix @@ -1,5 +1,10 @@ { nixosConfig, pkgs, ... }: - +let + identity.DigitalerDienst = { + name = "Jakob Lechner"; + email = "j.lechner@digitaler-dienst.gmbh"; + }; +in { programs = { git = { @@ -157,6 +162,18 @@ end ''; }; + "fish_set_git_author_by_pwd" = { + description = "Set Git identity by PWD"; + body = '' + if string match -n $HOME'/digitaler-dienst/*' $PWD/ > /dev/null + if git rev-parse --git-dir >/dev/null 2>&1 + git config --local user.name >/dev/null || git config --local user.name "${identity.DigitalerDienst.name}" + git config --local user.email >/dev/null || git config --local user.email "${identity.DigitalerDienst.email}" + end + end + ''; + onVariable = "PWD"; + }; }; }; };