-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
122 lines (99 loc) · 3.38 KB
/
init.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
#!/bin/bash
# -----------------------------------------------
# A shell script to init servers
#
# Author: Lucy Park <[email protected]>
# Created: 2017-05-08
# Requirements: libevent, ncurses for tmux
# Usage:
#
# wget http://bit.ly/inite9t
# bash inite9t
# -----------------------------------------------
set -euo pipefail
# FILLME ----------------------------------------
home="$HOME"
install_dotfiles=1
install_packages=1
# -----------------------------------------------
os=$(uname)
# confirm home
read -r -p "Is \$HOME supposed to be \"$home\"? [y/N] " response
if ! [[ $response == "y" ]]; then
read -r -p "Enter a new \$HOME: " home
fi
read -r -p "Are you sure about this? [y/N] " response
if ! [[ $response == "y" ]]; then
echo "Aborting..."
exit 0
fi
for i in {5..1}; do
echo $i
sleep 1
done
# start setup
if [ $install_dotfiles -eq 1 ]; then
echo "# Install dotfiles..."
set -x # start debug mode
cd $home
# clone dotfiles if not exists
if [[ ! -f "$home/.zshrc" ]]; then
git clone https://github.com/e9t/dotfiles.git
mv dotfiles/* dotfiles/.[^.]* $home || echo "dotfiles already exist"
rmdir dotfiles
fi
# replace "$HOME with $home"
# if [[ $os == "Linux" ]]; then
# sed -i "5s@.*@export HOME=\"$home\"@" $home/.zshrc
# elif [[ $os == "Darwin" ]]; then
# sed -i '' "5s@.*@export HOME=\"$home\"@" $home/.zshrc
# fi
# update submodules
git submodule init
git submodule update
if [[ ! -d "$home/.rbenv/plugins/ruby-build" ]]; then
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
fi
set +x
fi
if [ $install_packages -eq 1 ]; then
echo "# Install packages..."
set -x # start debug mode
# For Ubuntu
# NOTE: tmux install by yum installs v1.8, will need manual install
if [[ $os == "Linux" ]]; then
apt update
apt install -y silversearcher-ag htop fasd git-lfs tmux
apt install -y neovim fzf
apt install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev # for pyenv
apt install -y zsh
# Install zoxide, if fails, install with the script below
# apt install zoxide
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
# Install pyenv
# curl https://pyenv.run | bash
elif [[ $os == "Darwin" ]]; then # Mac OSX
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install zoxide
brew install neovim
brew install pyenv
fi
# Install vim-plug
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
# Start pyenv and install python
export PYENV_ROOT="$home/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
pyenv install 3.10.1
pyenv global 3.10.1
# Enable pyenv-virtualenv
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
eval "$(pyenv virtualenv-init -)"
# Install python packages
# pip install ipython flake8 gpustat
set +x
fi
chsh -s $(which zsh)
# vim:sw=4:ts=4:et