-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·68 lines (60 loc) · 1.51 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
#!/bin/bash
setup() {
src=$1
tgt=$2
bak=$3
if [ ! -e "$tgt" ]; then
echo "ERROR in setup: $tgt does not exist."
return
fi
if [ -L $src ]; then
rm $src
elif [ -f $src ] || [ -d $src ]; then
mv $src $bak
fi
ln -s $tgt $src
}
logo() {
echo -e "\033[31m ____ _ __ _ _ \033[0m"
echo -e "\033[32m| _ \ ___ | |_ / _(_) | ___ ___ \033[0m"
echo -e "\033[33m| | | |/ _ \| __| |_| | |/ _ \/ __| \033[0m"
echo -e "\033[34m| |_| | (_) | |_| _| | | __/\__ \ \033[0m"
echo -e "\033[35m|____/ \___/ \__|_| |_|_|\___||___/ \033[0m"
}
main() {
current_dir=$(
cd "$(dirname "$0")"
pwd
)
backup_dir="$current_dir/.backup/"
mkdir -p "$backup_dir"
if [ "$1" == "all" ]; then
files=("~/.vimrc" "~/.condarc" "~/.zshrc" "~/.tmux.conf" "~/.config/nvim" "~/.config/ranger" "~/.config/starship.toml")
elif [ "$1" == "vim" ]; then
files=("~/.vimrc")
elif [ "$1" == "conda" ]; then
files=("~/.condarc")
elif [ "$1" == "zsh" ]; then
files=("~/.zshrc" "~/.config/starship.toml")
elif [ "$1" == "tmux" ]; then
files=("~/.tmux.conf")
elif [ "$1" == "nvim" ]; then
files=("~/.config/nvim")
elif [ "$1" == "ranger" ]; then
files=("~/.config/ranger")
else
files=()
echo "Nothing to setup"
fi
for filepath in ${files[@]}; do
echo "Setup" $filepath
filepath=$(eval echo "$filepath")
fname=$(basename $filepath)
setup $filepath $current_dir/$fname $backup_dir/$fname
done
logo
echo "Author: MiaoHN"
echo "Github: https://github.com/MiaoHN"
echo "Backup dir: $backup_dir"
}
main $@