-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·64 lines (59 loc) · 1.78 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
SRC_DIR="$(realpath $(dirname -- "${BASH_SOURCE[0]}"))"
link_dir() {
SRC=$1; DEST=$2;
mkdir -p "${DEST}"
for file in ${SRC_DIR}/${SRC}/*; do
file_dest="${DEST}"/$(basename ${file})
test -e ${file_dest} && continue
(
set -x
ln -sf "${file}" "${file_dest}"
)
done
}
link() {
SRC=$(realpath ${1}); DEST=$(realpath ${2});
(
set -x
ln -sf "${SRC}" "${DEST}"
)
}
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
link psqlrc ${HOME}/.psqlrc
git_config