-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·138 lines (106 loc) · 3.53 KB
/
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
#! /bin/bash
# ------------------------- setup global variables
# ----------- path
# ------------------------- collect variables
SETTINGS_ROOT=$(cd $(dirname $0); pwd)
read -p "input your name: " NAME
NAME=${NAME:-rugamaga}
read -p "input your email: " EMAIL
EMAIL=${EMAIL:[email protected]}
# ------------------------- setup functions
# create if not file exists
# otherwise, don't touch.
function create_if_missing () {
[[ -e "$1" ]] || cat - > "$1"
}
# ------------------------- install asdf
export TMPDIR="$HOME/.tmp"
mkdir -p $TMPDIR
[[ -s ~/.asdfrc ]] || ln -s ~/.asdfrc .asdfrc
[[ -d ~/.asdf ]] || git clone https://github.com/asdf-vm/asdf.git ~/.asdf
(
cd ~/.asdf
git checkout "$(git describe --abbrev=0 --tags)"
)
. $HOME/.asdf/asdf.sh
asdf plugin add ruby
asdf plugin add python
asdf plugin add nodejs
# ------------------------- install ruby
LATEST_RUBY=`asdf list all ruby | grep -v - | tail -1`
asdf install ruby $LATEST_RUBY
asdf global ruby $LATEST_RUBY
gem install bundler
gem install neovim
# ------------------------- install python
LATEST_PYTHON2=`asdf list all python | grep -e "^\s*2\.[0-9]\+\.[0-9]\+$" | tail -1`
asdf install python $LATEST_PYTHON2
asdf global python $LATEST_PYTHON2
pip install pynvim
LATEST_PYTHON=`asdf list all python | grep -e "^\s*[0-9]\+\.[0-9]\+\.[0-9]\+$" | tail -1`
asdf install python $LATEST_PYTHON
asdf global python $LATEST_PYTHON
pip install pynvim
pip install --user pipenv
# install poetry (package bundler)
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
# ------------------------- install nodejs
bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
LATEST_NODEJS=`asdf list all nodejs | grep -v - | tail -1`
asdf install nodejs $LATEST_NODEJS
asdf global nodejs $LATEST_NODEJS
npm install -g typescript
npm install -g neovim
npm install -g typescript-language-server
npm install -g dockerfile-language-server-nodejs
npm install -g vim-language-server
npm install -g vscode-json-languageserver
# ------------------------- output template
# ------------ .zshrc
create_if_missing "$HOME/.zshrc" << EOS
# ------------------------- variables
# profiling mode
PROFILING=false
# dotfiles directory
export SETTINGS_ROOT="${SETTINGS_ROOT}"
# ------------------------- start profiling
if \$PROFILING; then
zmodload zsh/zprof && zprof
fi
# ------------------------- load common config
source "${SETTINGS_ROOT}/.zshrc"
# ------------------------- environment specific configs
# (you can setup environment specific configs here)
# ------------------------- end profiling
if \$PROFILING ; then
if (which zprof > /dev/null 2>&1) ;then
zprof
fi
fi
EOS
# ------------ .zshenv
create_if_missing "$HOME/.zshenv" << EOS
source $SETTINGS_ROOT/.zshenv
EOS
# ------------ .gitconfig
create_if_missing "$HOME/.gitconfig" << EOS
[user]
email = ${EMAIL}
name = ${NAME}
[include]
path = ${SETTINGS_ROOT}/.gitconfig
EOS
# ------------ .config/nvim/init.vim
mkdir -p $HOME/.config/nvim/
create_if_missing "$HOME/.config/nvim/init.vim" << EOS
let g:python_host_prog = '$HOME/.asdf/installs/python/${LATEST_PYTHON2}/bin/python2'
let g:python3_host_prog = '$HOME/.asdf/installs/python/${LATEST_PYTHON}/bin/python'
" ------------------------- load common
source ${SETTINGS_ROOT}/.nvimrc
EOS
# ------------------------- .tmux.conf
# TODO: if there exists external file importing method, use the method.
create_if_missing "$HOME/.tmux.conf" << EOS
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm*:Tc:sitm=\E[3m"
EOS