diff --git a/packages/packages.sh b/packages/packages.sh index 4a778d3..c58ea96 100755 --- a/packages/packages.sh +++ b/packages/packages.sh @@ -162,6 +162,49 @@ if has_tags pm:pipx; then thefuck fi +# change git user settings + +set_git_config_if_unset() { + local name + local value + name="$1" + value="$2" + if ! git config --global --get "$1" >/dev/null; then + echo "Configuring global git setting: $1 = $2" + git config --global "$1" "$2" + fi +} + +clear_git_config_if_pointing_nowhere() { + local name + name="$1" + if git config --global --get "$1" >/dev/null && ! command -v $(git config --global --get "$1") >/dev/null; then + echo "Resetting global git setting since it no longer points anywhere useful: $1" + git config --global --unset "$1" + fi +} + +set_git_config_if_unset alias.change-commits '!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '"'"'$OLD'"'"' ]]; then export $VAR='"'"'$NEW'"'"'; fi\" $@; }; f' +set_git_config_if_unset alias.glog 'log --all --pretty="format:%d %Cgreen%h%Creset %an - %s" --graph' +set_git_config_if_unset commit.gpgsign true +set_git_config_if_unset core.autocrlf input +set_git_config_if_unset core.editor "$EDITOR" +set_git_config_if_unset init.defaultBranch main +set_git_config_if_unset pull.rebase false +set_git_config_if_unset tag.gpgsign true +set_git_config_if_unset user.email "icedream@icedream.pw" +set_git_config_if_unset user.name "Carl Kittelberger" +#set_git_config_if_unset user.signingkey B5108C5A158A6608AD3361DA1573F6D8EFE4D0CF +set_git_config_if_unset user.signingkey 04ADEF85EA6AEC6F75941E84468BBEEBB9EC6AEA + +# set up kdiff3 as mergetool if it is installed +clear_git_config_if_pointing_nowhere merge.tool +for bin in kdiff3 meld p4merge vimdiff; do + if command -v "$bin" >/dev/null; then + set_git_config_if_unset merge.tool "$bin" + fi +done + # change default terminal to urxvt if has_tags desktop; then