-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·53 lines (42 loc) · 1.35 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
#!/usr/bin/env bash
set -e
set -o pipefail
# ~ Install vim and nvim files symlinks to home directory
# with backing up previous versions if exists
# ~ Ui Helpers
function echo_ok() { echo -e '\033[1;32m'"$1"'\033[0m'; }
function echo_warn() { echo -e '\033[1;33m'"$1"'\033[0m'; }
function echo_error() { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; }
# ~ Install symlinks
dotfiles_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
dotfiles=(
".vim"
".vimrc"
".ctags"
)
echo_warn "Creating symlinks"
for item in ${dotfiles[*]}
do
target="$dotfiles_dir/$item"
if [ -e "$target" ]; then
echo_warn "Symlinking: ${HOME}/${item} -> $target"
new_link="${HOME}/${item}"
rm -rf "$new_link"
ln -s "$target" "$new_link" || { echo_error "Link creation failed" && exit 1; }
echo_ok "OK"
fi
done
# ~ install init.vim for nvim
# TODO: add echoing >> here (for nvim init content)
mkdir -p ~/.config/nvim/
nvim_init_file="${HOME}/.config/nvim/init.vim"
if ! [ -f "${nvim_init_file}" ]; then
mkdir -p "${HOME}/.config/nvim/"
cp "${dotfiles_dir}/init.vim" "${nvim_init_file}"
fi
# ~ download vim package manager if missing
test -f $HOME/.vim/autoload/plug.vim || { \
echo_warn "Installing vim package manager";
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim;
}