-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall
More file actions
executable file
·89 lines (79 loc) · 1.79 KB
/
install
File metadata and controls
executable file
·89 lines (79 loc) · 1.79 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
EXCLUDE_FILES=(README.md install .gitignore .git .config .local)
DOTFILES=$(realpath `dirname -- "${BASH_SOURCE[0]}"`)
OPTSTRING=":bh"
NOBKP=""
_install() {
echo "installing $1"
if [ -e "$HOME/$1" ]; then
if [ -z "${NOBKP}" ]; then
rm -r "$HOME/$1"
else
mv "$HOME/$1" "$HOME/$1".bck
fi
fi
ln -s "$DOTFILES/$1" "$HOME/$1"
}
install_root_dot_files() {
for f in $(ls -a $DOTFILES)
do
if [[ ! $(echo ${EXCLUDE_FILES[@]} | grep -w $f) ]]; then
_install "$f"
fi
done
}
install_config_files() {
mkdir -p ~/.config
for f in $(ls $DOTFILES/.config)
do
if [[ ! $(echo ${EXCLUDE_FILES[@]} | grep -w .config/$f) ]]; then
_install ".config/$f"
fi
done
}
install_local_bin_files() {
mkdir -p ~/.local/bin/
for f in $(ls $DOTFILES/.local/bin)
do
if [[ ! $(echo ${EXCLUDE_FILES[@]} | grep -w .local/bin/$f) ]]; then
_install ".local/bin/$f"
fi
done
}
usage() {
script_name=$(basename -- "${BASH_SOURCE[0]}")
echo "usage: $script_name [-b|h]"
echo " -b create bkp files instead of removing old configs"
echo " -h shows this help message"
}
setup_vim() {
echo "Cloning minpac package for vim"
mkdir -p ~/.config/vim/pack/minpac/opt
pushd ~/.config/vim/pack/minpac/opt
git clone git@github.com:k-takata/minpac.git
popd
echo "minpac installed."
echo "you should complete vim install by running vim +PackUpdateAndQuit +q"
}
while getopts ${OPTSTRING} opt; do
case ${opt} in
b)
NOBKP=1
;;
h)
usage
exit 0
;;
?)
echo "Invalid option: -${OPTARG}."
exit 1
;;
esac
done
echo "installing config files from $DOTFILES"
install_root_dot_files
install_config_files
install_local_bin_files
setup_vim
echo "installation finished. You may need to complete the set up for progrmas"
echo "like vim (:PackUpdate) and neovim (:Lazy and :Mason)"