-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv-setup.sh
executable file
·191 lines (165 loc) · 4.34 KB
/
env-setup.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
##### Notes #####
# Map at the system level Caps Lock to Control
# Powerline/iTerm2 setup: https://coderwall.com/p/yiot4q/setup-vim-powerline-and-iterm2-on-mac-os-x
# Fonts: git clone https://github.com/powerline/fonts.git && cd fonts && ./install.sh
# Set iTerm2 font (non-ASCII too) to be: Inconsolata for powerline 14pt
# pyenv setup:
# curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
# or with package manager (yum, dnf, brew)
#
# pyenv install 2.7.15
# PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.6.5
#
# pyenv virtualenv 2.7.15 nvim2
# pyenv virtualenv 3.6.5 nvim3
#
# pyenv activate nvim2
# pip install neovim
# pip install pynvim
# pyenv which python # Note the path
#
# pyenv activate nvim3
# pip install neovim
# pip install pynvim
# pyenv which python # Note the path
#
# YCM:
# cd to YCM dir:
# ./install.py --clang-completer --go-completer --java-completer
# or for linux:
# ./install.py --go-completer --java-completer
DIR=$(cd $(/usr/bin/dirname $0) 2>/dev/null && pwd)
DOTFILES=(
.bash_completion
.bash_profile
.config/nvim/init.vim
.gitconfig
.gitignore
.motd
.shellrc-bash
.shellrc-zsh
.shellrc.d/01-setup
.shellrc.d/diff-so-fancy
.shellrc.d/oh-my-zsh
.shellrc.d/pyenv
.shellrc.d/rbenv
.shellrc.d/speedtest-cli
.shellrc.d/ssh-agent-config
.shellrc.d/vim
.shellrc.d/zzz-setup
.vim/fzfcmd
.vimrc
.zshrc
)
FILE_SCRIPTS=(
count-ctl-m.sh
count-loc.sh
remove-tabs.sh
replace-space-underscore.sh
find-in-jar
)
GIT_SCRIPTS=(
git-changed
git-files-changed
git-rec
)
VAGRANT_SCRIPTS=(
vagrantplus
)
SSH_SCRIPTS=(
ssh-config
)
OTHER_SCRIPTS=(
screen-grep
fullload
)
BREW=(
brewdeps
)
indent() {
local string="${1}"
local num_spaces="${2}"
while read -r line; do
printf "%${num_spaces}s%s\n" '' "${line}"
done <<< "${string}"
}
cleanup_dir() {
dir="$1"
rm -rf "${dir}"
}
setup_powerline_fonts() {
indent 'Installing powerline fonts.' 0
tmp_dir=$(mktemp -d /tmp/env-setup.XXXXXX)
pushd $tmp_dir > /dev/null
indent "$(git clone -q https://github.com/powerline/fonts.git && cd fonts && ./install.sh)" 4
popd > /dev/null
trap "cleanup_dir ${tmp_dir}" EXIT
}
symlink_dir() {
local dir_prefix=$1
local target_dir=$2
local file=$3
target="$target_dir/$file"
if [ ! -d "$(/usr/bin/dirname $target)" ]; then
indent "Base dir for $target does not exist, creating it..." 4
mkdir -p $(/usr/bin/dirname $target)
fi
if [ -L "$target" ]; then
indent "$target is already symlinked." 4
elif [ -e "$target" ]; then
indent "$target is already a file." 4
else
indent "Symlinking $target." 4
ln -s "$dir_prefix/$file" "$target"
fi
}
symlink_dirs() {
local dir_prefix=$1
local target_dir=$2
local file_arr=("${!3}")
for i in "${file_arr[@]}"; do
symlink_dir "${dir_prefix}" "${target_dir}" ${i}
done
}
main() {
##### Setup VIM ####
mkdir -p "${HOME}/.vim/tmp"
# Vim Plug Setup
mkdir -p "${HOME}/.vim/plugged"
mkdir -p "${HOME}/.vim/autoload"
mkdir -p "${HOME}/.local/share/nvim/site"
if [ ! -L "${HOME}/.local/share/nvim/plugged" ]; then
ln -s "${HOME}/.vim/plugged" "${HOME}/.local/share/nvim/plugged"
fi
if [ ! -L "${HOME}/.local/share/nvim/site/autoload" ]; then
ln -s "${HOME}/.vim/autoload" "${HOME}/.local/share/nvim/site/autoload"
fi
curl -sfLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Powerline fonts
if [ "$1" != "--no-fonts" ]; then
indent "Setting up Powerline fonts:" 0
setup_powerline_fonts
fi
cd ${DIR}
#### Setup Script/RC symlinks ####
indent "Symlinking scripts and dotfiles:" 0
mkdir -p $HOME/bin
symlink_dirs "$DIR/dotfiles" $HOME DOTFILES[@]
symlink_dirs "$DIR/file_scripts" "$HOME/bin" FILE_SCRIPTS[@]
symlink_dirs "$DIR/ssh_config" "$HOME/bin" SSH_SCRIPTS[@]
symlink_dirs "$DIR/git" "$HOME/bin" GIT_SCRIPTS[@]
symlink_dirs "$DIR/vagrant_mgmt" "$HOME/bin" VAGRANT_SCRIPTS[@]
symlink_dirs "$DIR/other_scripts" "$HOME/bin" OTHER_SCRIPTS[@]
symlink_dirs "$DIR/brew" "$HOME/bin" BREW[@]
#### Extra Setup ####
indent "Running extra setup if available:" 0
if [ -f ~/.env-setup-extra ]; then
indent "Found ~/.env-setup-extra:" 4
bash ~/.env-setup-extra
fi
indent "Setup Complete" 0
exit 0
}
main "$@"