From 5f942ee17cc0fe063f1c76ba0c33f64c50fe9a51 Mon Sep 17 00:00:00 2001 From: RageCage64 Date: Thu, 29 Feb 2024 11:22:24 -0500 Subject: [PATCH] git profiles --- git_profile_setup.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 git_profile_setup.sh diff --git a/git_profile_setup.sh b/git_profile_setup.sh new file mode 100644 index 0000000..abfc4a3 --- /dev/null +++ b/git_profile_setup.sh @@ -0,0 +1,31 @@ +# Create a new profile in ~/.config/Git +read -p "Enter git username: " NAME +read -p "Enter Email: " EMAIL + +mkdir -p ~/.config/Git + +PROFILE_PATH=~/.config/Git/git-profile-${NAME}.conf + +cat <> $PROFILE_PATH +[user] + email = $EMAIL + name = $NAME +[core] + editor = nvim +EOT + +# Include the profile in gitconfig +touch ~/.gitconfig +read -p "Default profile? (y/n) " DEFAULT +if [ "$DEFAULT" != "y" ]; then + read -p "Enter profile directory (for example '~/Work'): " DIR + cat <> ~/.gitconfig +[includeIf "gitdir:${DIR}/**"] + path = $PROFILE_PATH +EOT +else + cat <> ~/.gitconfig +[include] + path = $PROFILE_PATH +EOT +fi