-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_ubuntu
executable file
·183 lines (142 loc) · 5.5 KB
/
setup_ubuntu
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
#!/usr/bin/env bash
# reference: https://github.com/anishathalye/dotfiles
# reference: https://github.com/dhruvmanila/dotfiles
# declare integer
declare -i exitcode
exitcode=0
# get base directory
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# # dotfiles directory
# declare DOTFILES_DIRECTORY="${HOME}/dotfiles"
# declare DOTFILES_TARBALL_PATH="https://github.com/MarkHershey/dotfiles/tarball/master"
# declare DOTFILES_GIT_REMOTE="https://github.com/MarkHershey/dotfiles.git"
# source utility functions
source "${BASEDIR}/shell_utils" || { echo "Failed to source shell_utils" >&2;exit 1; }
# ----------------------------------------------------
# zsh
p_header "Install wget curl zsh vim git tmux tree make cmake golang python3 build-essential..."
{ sudo apt-get remove --assume-yes vim-tiny > /dev/null && \
sudo apt-get update > /dev/null && \
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \
wget \
curl \
zsh \
vim \
git \
tmux \
tree \
make \
cmake \
wmctrl \
neofetch \
golang-go \
python3-dev \
python3-pip \
python3-testresources \
build-essential > /dev/null; } || { echo "Failed" >&2;exit 1; }
p_success "Done"
# ----------------------------------------------------
# default shell
p_header "Change default shell to zsh"
# { chsh -s "$(which zsh)" && echo "$SHELL"; } || { echo "Failed" >&2;exit 1; }
{ sudo chsh ${USER} -s $(which zsh) && echo "${SHELL}"; } || { echo "Failed" >&2;exit 1; }
p_success "Done"
# ----------------------------------------------------
# Oh My ZSH
p_header "Install Oh My ZSH"
TMP_INSTALL_PATH="${HOME}/.oh-my-zsh"
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Oh My ZSH already installed."
fi
# ----------------------------------------------------
# Zsh Syntax Highlighting
p_header "Install Zsh Syntax Highlighting"
TMP_INSTALL_PATH="${HOME}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${TMP_INSTALL_PATH}" || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Zsh Syntax Highlighting already installed."
fi
# ----------------------------------------------------
# Zsh Autosuggestions
p_header "Install Zsh Autosuggestions"
TMP_INSTALL_PATH="${HOME}/.oh-my-zsh/custom/plugins/zsh-autosuggestions"
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
git clone https://github.com/zsh-users/zsh-autosuggestions "${TMP_INSTALL_PATH}" || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Zsh Autosuggestions already installed."
fi
# ----------------------------------------------------
# Zsh Completions
p_header "Install Zsh Completions"
TMP_INSTALL_PATH="${HOME}/.oh-my-zsh/custom/plugins/zsh-completions"
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
git clone https://github.com/zsh-users/zsh-completions "${TMP_INSTALL_PATH}" || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Zsh Completions already installed."
fi
# ----------------------------------------------------
# Powerlevel 10k
p_header "Install Powerlevel 10k"
TMP_INSTALL_PATH="${HOME}/.oh-my-zsh/custom/themes/powerlevel10k"
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${TMP_INSTALL_PATH}" || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Powerlevel 10k already installed."
fi
# ----------------------------------------------------
# Linking dotfiles
link_dotfile "zsh/zshrc" ".zshrc" || exitcode=1
link_dotfile "p10k/p10k.zsh" ".p10k.zsh" || exitcode=1
link_dotfile "tmux/tmux.conf" ".tmux.conf" || exitcode=1
link_dotfile "tmux/tmux.conf.local" ".tmux.conf.local" || exitcode=1
link_dotfile "vim/vimrc" ".vimrc" || exitcode=1
link_dotfile "git/gitconfig" ".gitconfig" || exitcode=1
mkdir -p "${HOME}/.config/git/"
link_dotfile "git/gitignore" ".config/git/ignore" || exitcode=1
mkdir -p "${HOME}/.config/terminator/"
link_dotfile "terminator/config" ".config/terminator/config" || exitcode=1
# ----------------------------------------------------
# Vim plugins
p_header "Install Vundle"
TMP_INSTALL_PATH="${HOME}/.vim/bundle/Vundle.vim"
# Check VundleVim URL
if curl --output /dev/null --silent --head --fail "https://github.com/VundleVim/Vundle.vim"; then
# Add your commands for section A here
if [[ ! -d "${TMP_INSTALL_PATH}" ]]; then
git clone https://github.com/VundleVim/Vundle.vim.git "${TMP_INSTALL_PATH}" || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
p_success "Vundle already installed."
fi
p_header "Install Vim plugins via Vundle"
vim +PluginInstall +qall > /dev/null || { echo "Failed" >&2;exit 1; }
p_success "Done"
else
echo "The VundleVim URL is not valid. Skipping VundleVim."
fi
# ----------------------------------------------------
# Personal scripts
p_header "Copy personal scripts to user home bin"
if [[ ! -d "${HOME}/bin" ]]; then
mkdir -v "${HOME}/bin" || { echo "Failed" >&2;exit 1; }
fi
# -n for do not overwriting
# -v for verbose
cp -vn bin/* "${HOME}/bin"
p_success "Done"
# ----------------------------------------------------
# Exit
if [ ! ${exitcode} -eq 0 ]; then
echo "Some parts failed"
else
p_success "------ All Completed ------"
fi
exit ${exitcode}