You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dotfiles/git_profile_setup.sh

32 lines
648 B
Bash

# 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 <<EOT >> $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 <<EOT >> ~/.gitconfig
[includeIf "gitdir:${DIR}/**"]
path = $PROFILE_PATH
EOT
else
cat <<EOT >> ~/.gitconfig
[include]
path = $PROFILE_PATH
EOT
fi