git profiles
parent
aa465386e5
commit
5f942ee17c
@ -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 <<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
|
Loading…
Reference in New Issue