Skip to content

Commit

Permalink
setup .gitconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
EnigmaCurry committed Dec 10, 2023
1 parent eb8ed57 commit d86628a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,42 @@ link() {
)
}

ask() {
## Ask the user a question and set the given variable name with their answer
## If the answer is blank, repeat the question.
local __prompt="${1}"; local __var="${2}"; local __default="${3}"
while true; do
read -e -p "${__prompt}"$'\x0a\e[32m:\e[0m ' -i "${__default}" ${__var}
export ${__var}
[[ -z "${!__var}" ]] || break
done
}

git_config() {
local GIT_USERNAME GIT_EMAIL
echo "## Setting up global git client config (~/.gitconfig) ..."
if ! git config --global user.name >/dev/null; then
ask "Enter your git name (eg. John Doe)" GIT_USERNAME
git config --global user.name "${GIT_USERNAME}"
fi
if ! git config --global user.email >/dev/null; then
ask "Enter your git email address (eg. [email protected])" GIT_EMAIL
git config --global user.email "${GIT_EMAIL}"
fi
if ! git config --global pull.rebase >/dev/null; then
git config --global pull.rebase false
fi
if ! git config --global init.defaultBranch >/dev/null; then
git config --global init.defaultBranch master
fi
echo
cat ~/.gitconfig
echo
}

link_dir config ${HOME}/.config
link_dir bin ${HOME}/bin
link bash_profile ${HOME}/.bash_profile
link bashrc ${HOME}/.bashrc
link inputrc ${HOME}/.inputrc

git_config

0 comments on commit d86628a

Please sign in to comment.