-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·70 lines (59 loc) · 1.81 KB
/
install.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
65
66
67
68
69
70
#!/bin/sh
APP_NAME='dot-files'
[ -z "$VIM_PATH" ] && DOT_PATH="$HOME/.dot-files"
[ -z "$REPO_URI" ] && REPO_URI='https://github.com/joshua7v/dot-files.git'
msg() {
printf '\t---> %b\n' "$1" >&2
}
success() {
msg "\33[32m ✔ \33[0m ${1}${2}"
}
error() {
msg "\33[31m ✘ \33[0m ${1}${2}"
exit 1
}
warn() {
msg "\33[33m ⚠ \33[0m ${1}${2}"
}
info() {
msg "\33[32m ➜ \33[0m ${1}${2}"
}
lnif() {
if [ ! -e $2 ] ; then
ln -s $1 $2
fi
}
if [ ! -e "DOT_PATH" ]; then
info "clone dot-files to $DOT_PATH"
mkdir -p "$DOT_PATH"
git clone "$REPO_URI" "$DOT_PATH"
ret="$?"
success "Successfully cloned $APP_NAME"
else
info "update dot-files in $DOT_PATH"
cd "$DOT_PATH" && git pull origin
ret="$?"
success "Successfully updated $APP_NAME"
fi
info "backing up current configrations"
today=`date +%Y%m%d`
mv $HOME/.bash_profile $HOME/.bash_profile.$today
mv $HOME/.bashrc $HOME/.bashrc.$today
mv $HOME/.zshrc $HOME/.zshrc.$today
mv $HOME/.tmux.conf $HOME/.tmux.conf.$today
mv $HOME/.npmrc $HOME/.npmrc.$today
mv $HOME/Library/Application\ Support/Code/User/settings.json $HOME/Library/Application\ Support/Code/User/settings.json.$today
success "successfully backed up your configurations"
info "installing tpm"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
success "sucessfully installed tpm"
info "setting up symlinks"
lnif $DOT_PATH/bash_profile $HOME/.bash_profile
lnif $DOT_PATH/bashrc $HOME/.bashrc
lnif $DOT_PATH/zshrc $HOME/.zshrc
lnif $DOT_PATH/tmux.conf $HOME/.tmux.conf
lnif $DOT_PATH/npmrc $HOME/.npmrc
cd "$DOT_PATH"/vifm && git clone https://github.com/vifm/vifm-colors colors
lnif $DOT_PATH/vifm $HOME/.vifm
lnif $Dot_PATH/vscode.json $HOME/Library/Application\ Support/Code/User/settings.json
success "successfully created symbol links"