-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu
188 lines (156 loc) · 5.28 KB
/
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
184
185
186
187
188
#!/usr/bin/env bash
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Update the current system before doing anything
sudo apt update && sudo apt upgrade -y
install_thoughtbot() {
# shellcheck disable=SC2154
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin"
fi
if [ ! -f "$HOME/.zshrc" ]; then
touch "$HOME/.zshrc"
fi
# Install basic dotfiles
if [ -d "$HOME/.dotfiles" ]; then
cd "$HOME/.dotfiles"
git pull
cd "$HOME/.dotfiles-local"
git pull
else
# Clone dotfiles
git clone git://github.com/thoughtbot/dotfiles.git "$HOME/.dotfiles"
git clone https://github.com/execat/dotfiles-local.git "$HOME/.dotfiles-local"
# Install RCM for linking dotfiles
sudo add-apt-repository ppa:martin-frost/thoughtbot-rcm
sudo apt update
sudo apt install rcm
fi
env RCRC=$HOME/.dotfiles/rcrc rcup
rcup
}
install_apt() {
sudo apt install -y cloc emacs fasd git-extras git-flow howdoi neovim tree vim wget zsh
# All utils
sudo apt install -y bash cowsay findutils mlocate moreutils binutils diffutils libsqlite3-dev sqlite3
sudo apt install -y libssl-dev libreadline-dev zlib1g-dev # For Ruby
sudo apt install -y python3-dev python3-pip
sudo pip3 install thefuck
}
install_packages() {
if [ ! -d "$HOME/.fzf" ]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
fi
# Export path with rbenv
# Irrespective of rbenv existing because it will exist soon if it doesn't already
export PATH="$HOME/.bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
if [ ! -d "$HOME/.rbenv" ]; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
~/.rbenv/bin/rbenv init || true
mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
git clone https://github.com/rbenv/rbenv-default-gems.git $(rbenv root)/plugins/rbenv-default-gems
cat > ~/.rbenv/default-gems <<EOF
bundler
pry
activesupport
EOF
echo 'Wrote default gems file'
fi
}
install_binaries() {
# Check their GitHub: https://github.com/thisredone/rb
echo 'Downloading and saving binaries'
curl https://raw.githubusercontent.com/thisredone/rb/master/rb -o ~/.bin/rb && chmod a+x ~/.bin/rb
}
run_script() {
rbenv init || true
rbenv install jruby-9.2.0.0
rbenv install 2.5.3
rbenv global 2.5.3
mkdir -p _code
}
# Install ohmyzsh
install_ohmyzsh() {
if [ -d "$HOME/.oh-my-zsh" ]; then
cd "$HOME/.oh-my-zsh"
git pull
else
# Do entire oh-my-zsh installation but don't drop in the Zsh session (last line of the script)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | grep -v 'env zsh' | grep -v 'chsh -s')"
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $HOME/.oh-my-zsh/custom/plugins/you-should-use
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
chmod g-w,o-w ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
echo "Now customizing zsh setup"
# Change theme (remove '' if not on macOS)
# sed -i "s/robbyrussell/af-magic/g" ~/.zshrc
sed -i "s/robbyrussell/af-magic/g" ~/.zshrc
cat >> ~/.zshrc <<EOF
# Local config
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
# aliases
[[ -f ~/.aliases ]] && source ~/.aliases
export PATH="\$HOME/.bin:\$HOME/.rbenv/bin:\$HOME/.rbenv/shims:\$PATH"
eval "\$(rbenv init -)"
EOF
fi
# Use .dotfiles and .dotfiles-local to create aliases
rcup -d .dotfiles -d .dotfiles-local
}
# Install SpaceVim for neovim
install_spacevim() {
if [ -d "$HOME/.SpaceVim" ]; then
cd "$HOME/.SpaceVim"
git pull
else
curl -sLf https://spacevim.org/install.sh | bash -s -- --install neovim
sudo pip3 install neovim
if [ -d "$HOME/.SpaceVim.d" ]; then
echo "Moving init.toml"
mv ~/.SpaceVim.d/init.toml{,.bak}
cat > ~/.SpaceVim.d/init.vim <<EOF
let g:spacevim_plugin_bundle_dir = '~/.cache/vimfiles/'
call SpaceVim#layers#load('lang#ruby')
call SpaceVim#layers#load('ctrlp')
call SpaceVim#layers#load('shell')
let g:spacevim_custom_plugins = [
\ ['sotte/presenting.vim'],
\ ]
set clipboard+=unnamedplus
" Use the arrows to something usefull
map <right> :bn<CR>
map <left> :bp<CR>
" Close all the buffers
map <leader>ba :1,300 bd!<CR>
set wrap
EOF
else
echo "Folder not found"
fi
fi
}
show_final_messages() {
cat << END
Go to Trackpad and uncheck and check the "Tap to click" and "Secondary click" option.
Also move click to "light" and turn on silent clicking.
Also do these things manually:
1. Set up .ssh keys (copy or create new)
2. Start jdiskreport and run mlocate
3. Set up keyboards for your preferred languages and layouts
4. Change shell by executing 'chsh -s $(grep /zsh$ /etc/shells | tail -1)'
Finally, close this tab and all the previously opened terminal tabs and continue working in a new tab.
END
}
install_thoughtbot
install_apt
install_packages || true
install_binaries
run_script
install_ohmyzsh
install_spacevim
show_final_messages