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