-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-vim.sh
executable file
·81 lines (70 loc) · 1.79 KB
/
setup-vim.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
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# vim:sts=4 sw=4 et
# Install third party software packages needed by Vim
# Copyright 2020 Andrew Bettison
source "$HOME/.bash_profile"
__shellboost_include libsh/script.sh || exit $?
usage() {
echo "$0 [-f|--force] [-n|--dry-run]"
}
set -e
opt_dry_run=false
opt_force=false
while [[ $# -gt 0 ]]; do
case "$1" in
'-?'|-h|--help)
usage
exit 0
;;
-f|--force)
opt_force=true
shift
;;
-n|--dry-run)
opt_dry_run=true
shift
;;
-*)
fatal_usage "unsupported option: $1"
;;
*)
break
;;
esac
done
[[ $# -eq 0 ]] || fatal_usage "spurious arguments: $*"
link() {
local src="${1?}"
local dst="${2?}"
[[ $src -ef $dst ]] || run ln -snrf "$src" "$dst"
}
fetch() {
local dst="${1?}"
local url="${2?}"
[[ $dst = */ ]] && dst="$dst${url##*/}"
if $opt_force || [ ! -e $dst ]; then
run curl --fail --location --silent --show-error --create-dirs -o "$dst" "$url"
fi
}
git_clone() {
local dst="${1?}"
local url="${2?}"
local stem="${url##*/}"
local stem="${stem%.git}"
[[ $dst = */ ]] && dst="$dst$stem"
if $opt_force || [ ! -d $dst/.git ]; then
[[ -e $dst ]] && rm -rf "$dst"
run mkdir -p "$dst"
run git clone "$url" "$dst"
fi
}
if [[ ! $(fc-list Inconsolata) ]]; then
run sudo apt update
run sudo apt install fonts-inconsolata
fi
# For Neovim
fetch ~/.local/share/nvim/site/autoload/ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
git_clone ~/.local/share/nvim/site/package/ git@github.com:quixotique/vim-delta.git
# For Vim
link ~/.local/share/nvim/site/autoload/plug.vim ~/.vim/autoload/plug.vim
link ~/.local/share/nvim/site/package/vim-delta ~/.vim/package/vim-delta