-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·63 lines (52 loc) · 1.45 KB
/
install.sh
File metadata and controls
executable file
·63 lines (52 loc) · 1.45 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
#!/usr/bin/env bash
set -eou pipefail
# This script installs .vim and .vimrc to a specified output directory.
# You can either install the files as copies (with the -c option) or
# as symlinks to the files in this directory.
#
# This script does NOT do plugin installation; the YCM compilation step
# is a bit different for some of my workflows. It's a one-time setup
# anyways.
do_copy=0
install_location=~
while getopts "o:hc" opt; do
case $opt in
c)
do_copy=1
;;
o)
install_location="$OPTARG"
;;
h | *)
echo "usage: install.sh [-h] [-c] [-o output_dir]"
exit 0
;;
esac
done
mkdir -p "$install_location"
remove_old_files() {
local dst=$1
if [[ -f "$dst" || -d "$dst" || -L "$dst" ]]; then
read -p "Removing $dst. OK? (y to confirm) "
if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
rm -rf "$dst"
else
echo "Aborted."
exit 1
fi
fi
}
dst_vim_dir="$install_location"/.vim
dst_vimrc="$install_location"/.vimrc
remove_old_files "$install_location"/.vim
remove_old_files "$install_location"/.vimrc
script_dir=$(dirname $(realpath "$0"))
src_vim_dir="$script_dir"/.vim
src_vimrc="$script_dir"/.vimrc
if (("$do_copy")); then
cp -r "$src_vim_dir" "$dst_vim_dir"
cp "$src_vimrc" "$dst_vimrc"
else
ln -s "$src_vim_dir" "$dst_vim_dir"
ln -s "$src_vimrc" "$dst_vimrc"
fi