-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·272 lines (227 loc) · 10.1 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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#! /bin/bash
#
# install.sh
# Copyright (C) 2017 Erlend Ekern <dev@ekern.me>
#
# Distributed under terms of the MIT license.
#
set -e
trap ERR
TIMESTAMP=$(date +%s)
LOG_FILE=~/log_stekern_dotfiles_$TIMESTAMP.txt
function confirm {
while true; do
read -p "$1" yn
case $yn in
[yY]* ) return 0;;
[nN]* ) return 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
function symlink {
file=$(realpath "$1") &>>$LOG_FILE
if [ -f "$2" ]; then
if confirm "File '$2' already exists. Rename it to '$2.$TIMESTAMP.old'? "; then
mv "$2" "$2.$TIMESTAMP.old" &>>$LOG_FILE
else
return 0
fi
fi
[ -f "$file" ] && mkdir -p "$(dirname $2)" && sudo ln -s "$file" "$2" &>>$LOG_FILE
}
# Clone dotfiles repo
if [ ! -d ~/dotfiles ]; then
# Install git
if [ "$(which git)" == "" ]; then
echo "[+] Installing git ..."
sudo apt install -y git &>>$LOG_FILE
fi
git clone https://github.com/stekern/dotfiles ~/dotfiles &>>$LOG_FILE
cd ~/dotfiles
else
echo "[-] Directory ~/dotfiles/ already exists! Exiting ..."
exit 1
fi
#####################################################
# #
# MISC. INSTALLATION CONFIGURATION #
# #
#####################################################
# Set up automatic installation of a required package
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
#####################################################
# #
# MAIN INSTALLATION PHASE #
# #
#####################################################
if confirm "Would you like to install albert, Spotify and misc. media packages? "; then
echo "[+] Installing albert, Spotify and misc. media packages ..."
{
# Add signing keys for albert repository
wget -nv -O Release.key https://build.opensuse.org/projects/home:manuelschneid3r/public_key
sudo apt-key add - < Release.key && rm Release.key
# Add repository for albert
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_18.04/ /' > /etc/apt/sources.list.d/home:manuelschneid3r.list"
# Add signing keys for Spotify repository
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90
# Add repository for Spotify
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt update
sudo apt install -y albert spotify-client ubuntu-restricted-extras
# Install necessary libraries for Spotify local files
sudo wget -N https://github.com/ramedeiros/spotify_libraries/raw/master/libavcodec.so.54.71.100 -O /usr/lib/x86_64-linux-gnu/libavcodec.so.54 && sudo wget -N https://github.com/ramedeiros/spotify_libraries/raw/master/libavformat.so.54.36.100 -O /usr/lib/x86_64-linux-gnu/libavformat.so.54 && sudo wget -N https://github.com/ramedeiros/spotify_libraries/raw/master/libavutil.so.52.6.100 -O /usr/lib/x86_64-linux-gnu/libavutil.so.52 && sudo ldconfig
} &>>$LOG_FILE
fi
if confirm "Would you like to install htop, tldr and tlp? "; then
echo "[+] Installing htop, tldr and tlp ..."
sudo apt install -y htop tldr tlp &>>$LOG_FILE
fi
if confirm "Would you like to configure misc. ThinkPad T460 tweaks? "; then
echo "[+] Configuring misc. ThinkPad T460 tweaks ..."
{
# xdotool is needed for keyboard configuration
# gnome-sushi is needed for file/folder previews in nautilus
# p7zip-full is needed to extract password-protected .zip-files
sudo apt install -y xdotool gnome-sushi p7zip-full
# Misc. modules for tlp
sudo apt install -y tlp-rdw acpi-call-dkms
# Only show apps in the current workspace when using <Alt><Tab>
gsettings set org.gnome.shell.app-switcher current-workspace-only "true"
# Map <Ctrl>+Volume keys to media prev, play, next
gsettings set org.gnome.settings-daemon.plugins.media-keys play "<Primary>AudioLowerVolume"
gsettings set org.gnome.settings-daemon.plugins.media-keys previous "<Primary>AudioMute"
gsettings set org.gnome.settings-daemon.plugins.media-keys next "<Primary>AudioRaiseVolume"
# Swap <CapsLock> and <Esc>
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']"
# Disable <Print>
gsettings set org.gnome.settings-daemon.plugins.media-keys screenshot ''
# Disable overview when pressing <Super>
gsettings set org.gnome.mutter overlay-key ''
# Cycle through application windows using <Alt>bar
gsettings set org.gnome.desktop.wm.keybindings switch-group "['<Alt>bar']"
gsettings set org.gnome.desktop.wm.keybindings switch-group-backward "['<Shift><Alt>bar']"
# Disable desktop icons
gsettings set org.gnome.desktop.background show-desktop-icons "false"
# Configure nautilus
gsettings set org.gnome.nautilus.list-view default-zoom-level "small"
gsettings set org.gnome.nautilus.list-view use-tree-view "true"
gsettings set org.gnome.nautilus.preferences default-folder-viewer "list-view"
# Set workspace labels
# gsettings set org.gnome.desktop.wm.preferences workspace-names "['Misc.', 'Thesis', 'Development', 'Coursework']"
# Enable natural scrolling for mouse
gsettings set org.gnome.desktop.peripherals.mouse natural-scroll "true"
# Disable Gnome overwriting custom xkb keyboard configurations
gsettings set org.gnome.settings-daemon.plugins.keyboard active "false"
# symlink "./thinkpad/10-trackpoint.rules" "/etc/udev/rules.d/10-trackpoint.rules"
# xinput --set-prop "TPPS/2 IBM TrackPoint" "libinput Natural Scrolling Enabled" 1
# xinput --set-prop "TPPS/2 IBM TrackPoint" "libinput Accel Speed" "-0.40"
} &>>$LOG_FILE
fi
# Install neovim, tmux and zsh
echo "[+] Installing neovim (+silversearcher-ag), tmux (+xclip) and zsh ..."
{
sudo add-apt-repository -y ppa:neovim-ppa/unstable
sudo apt update
sudo apt install -y neovim tmux zsh
# Additional installations for neovim and tmux
sudo apt install -y xclip silversearcher-ag
} &>>$LOG_FILE
# Install oh-my-zsh
if [ ! -d ~/.oh-my-zsh ]; then
echo "[+] Installing oh-my-zsh and custom plugins ..."
bash -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sed -r 's/(^\s*)(env zsh -l)(\s*$)/\1#\2\3/g' | sed -r 's/(^\s*)(chsh -s .*)(\s*)$/\1#\2\3/g')" &>>$LOG_FILE
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
chsh -s $(which zsh) 2>&1 | tee -a $LOG_FILE
fi
# Install nvm
if [ ! -d ~/.nvm ]; then
echo "[+] Installing nvm ..."
{
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
source ~/.nvm/nvm.sh
} &>>$LOG_FILE
echo "[+] Installing latest LTS version of Node.js ..."
nvm install --lts &>>$LOG_FILE
fi
if [ ! -d ~/.pyenv ]; then
# Install dependencies for pyenv
echo "[+] Installing dependencies for pyenv ..."
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev &>>$LOG_FILE
echo "[+] Installing pyenv ..."
git clone https://github.com/pyenv/pyenv.git ~/.pyenv &>>$LOG_FILE
fi
if [ ! -d ~/.pyenv/plugins/pyenv-virtualenv ]; then
echo "[+] Installing pyenv-virtualenv ..."
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv &>>$LOG_FILE
fi
if [ ! -d ~/.pyenv/plugins/pyenv-virtualenvwrapper ]; then
echo "[+] Installing pyenv-virtualenvwrapper ..."
git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper &>>$LOG_FILE
fi
has_python3=$(~/.pyenv/bin/pyenv versions | egrep '3.7.0' | wc -l)
if [ $has_python3 -eq 0 ]; then
echo "[+] Installing Python 3.7.0 ..."
~/.pyenv/bin/pyenv install 3.7.0 &>>$LOG_FILE
fi
has_python2=$(~/.pyenv/bin/pyenv versions | egrep '2.7.13' | wc -l)
if [ $has_python2 -eq 0 ]; then
echo "[+] Installing Python 2.7.13 ..."
~/.pyenv/bin/pyenv install 2.7.13 &>>$LOG_FILE
fi
~/.pyenv/bin/pyenv global 3.7.0 &>>$LOG_FILE
echo "[+] Installing misc. packages from pip ..."
{
~/.pyenv/shims/pip3.7 install --upgrade pip
~/.pyenv/shims/pip3.7 install virtualenv
~/.pyenv/shims/pip3.7 install virtualenvwrapper
~/.pyenv/shims/pip3.7 install neovim
} &>>$LOG_FILE
# Install powerline fonts
if [ $(ls ~/.local/share/fonts | grep 'Powerline' | wc -l) -lt 50 ]; then
echo "[+] Installing powerline fonts ..."
{
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts && ./install.sh
cd .. && rm -rf fonts
} &>>$LOG_FILE
fi
# Install base16-shell and set theme
if [ ! -d ~/.config/base16-shell ]; then
echo "[+] Installing base16-shell ..."
git clone https://github.com/chriskempson/base16-shell.git ~/.config/base16-shell &>>$LOG_FILE
fi
# Symlinking
declare -A symlinks=(
["./vim/vimrc"]=~/.config/nvim/init.vim
["gitconfig"]=~/.gitconfig
["tmux.conf"]=~/.tmux.conf
["zshrc"]=~/.zshrc
)
echo "[+] Setting up symbolic links ..."
for filename in "${!symlinks[@]}"; do
symlink "$filename" "${symlinks[$filename]}"
done
if [ "$(which vim)" == "" ]; then
sudo ln -s /usr/bin/nvim /usr/bin/vim &>>$LOG_FILE
fi
# Configure GNOME terminal
echo "[+] Configuring GNOME terminal ..."
{
default_profile=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d "'" )
gsettings_schema="org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$default_profile/"
gsettings set $gsettings_schema scrollbar-policy "never"
gsettings set $gsettings_schema use-theme-transparency "false"
gsettings set $gsettings_schema use-transparent-background "true"
gsettings set $gsettings_schema background-transparency-percent "3"
gsettings set $gsettings_schema font "Source Code Pro for Powerline Regular 11"
} &>>$LOG_FILE
echo ""
echo "------------------------------------"
echo "Installation of dotfiles has successfully finished!"
echo "You can view the installation log at: $LOG_FILE"
echo "------------------------------------"
echo ""
env zsh -l