-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·60 lines (46 loc) · 1.16 KB
/
bootstrap.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
#!/bin/bash
set -e
set -o pipefail
cd "$(dirname "$0")"
DOTFILES_ROOT=$(pwd -P)
echo $DOTFILES_ROOT
brew bundle
setup_gitconfig () {
if ! [ -f git/gitconfig.local.symlink ]
then
echo '-> setup gitconfig'
git_credential='cache'
if [ "$(uname -s)" == "Darwin" ]
then
git_credential='osxkeychain'
fi
echo ' - What is your github author name?'
read -e git_authorname
echo ' - What is your github author email?'
read -e git_authoremail
sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" git/gitconfig.local.symlink.example > git/gitconfig.local.symlink
echo 'gitconfig'
fi
}
link_file () {
local src=$1 dst=$2
if [ -f "$dst" -o -d "$dst" -o -L "$dst" ]
then
rm -rf "$dst"
echo " ! removed $dst"
fi
ln -s "$1" "$2"
echo " - linked $1 to $2"
}
install_dotfiles () {
echo '-> installing dotfiles'
for src in $(find -H "$DOTFILES_ROOT" -maxdepth 2 -name '*.symlink' -not -path '*.git*')
do
dst="$HOME/.$(basename "${src%.*}")"
link_file "$src" "$dst"
done
}
setup_gitconfig
install_dotfiles
echo "Done."
echo