forked from gambels/vim-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·111 lines (84 loc) · 2.49 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
set -u
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
echo "Installing vim-ide from $DIR"
VIMRC=$(cat << EOF
" =============================================================================
" File: .vimrc
" Description: Main vim run command script
" =============================================================================
" Using $DIR to find packages
set packpath^=$DIR
" Using $DIR as home "after" directory
set runtimepath+=$DIR/after
" No vi-compatible
set nocompatible
" =============================================================================
" Section: Configure vimrc
" =============================================================================
" Using $DIR to find vimrc files
let \$MYVIMRCPATH = "$DIR/vimrc"
let vimrc_misc = 1
let vimrc_keymap = 1
let vimrc_hard_ass = 1
let vimrc_functions = 1
let vimrc_commands = 1
let vimrc_filetypes = 1
let vimrc_plugins = 1
" =============================================================================
" Section: Load vimrc
" =============================================================================
if 1 == vimrc_misc
so $DIR/vimrc/misc.vim
endif
if 1 == vimrc_keymap
so $DIR/vimrc/keymap.vim
endif
if 1 == vimrc_hard_ass
so $DIR/vimrc/hard_ass.vim
endif
if 1 == vimrc_functions
so $DIR/vimrc/functions.vim
endif
if 1 == vimrc_commands
so $DIR/vimrc/commands.vim
endif
if 1 == vimrc_filetypes
so $DIR/vimrc/filetypes.vim
endif
if 1 == vimrc_plugins
so $DIR/vimrc/plugins.vim
endif
EOF
)
if [ $# -eq 0 ]; then
USERS=$(id -un)
elif [ "$1" == "--all" ]; then
USERS=$(getent passwd | grep /home | cut -d: -f1 | tr '\n' ' ')
else
USERS=${@:1}
fi
echo "Selected users: $USERS"
for USER in $USERS; do
user_home=$(eval echo "~$USER")
user_vimrc="${user_home}/.vimrc"
echo "$VIMRC" > "$user_vimrc" && chown "$USER:$USER" "$user_vimrc" || exit 1
echo "Installed the vim-ide configuration for user '$USER' successfully! Enjoy :-)"
done
echo "Install minpac .."
MINPAC_DIR="./pack/minpac/opt/minpac"
if [ -d "$MINPAC_DIR" ]; then
cd "$MINPAC_DIR" || exit 1
git pull || exit 1
else
git clone "https://github.com/k-takata/minpac.git" "$MINPAC_DIR" || exit 1
fi
echo "Update plugins .."
vim -N -u "$DIR"/vimrc/plugins.vim -c "set packpath^=$DIR" -c "PackInstall"
if [ $? -ne 0 ]; then
echo "PackInstall failed. Minpack installed? (see README.md)"
fi
echo "Update helptags .."
vim -N -u "$DIR"/vimrc/plugins.vim -c "silent! helptags ALL" -c "quit!"
exit 0
### EOF ###