-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb8ed57
commit d86628a
Showing
1 changed file
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |