|
#!/bin/bash |
|
|
|
# Stevie Howard | @stvhwrd |
|
# February 2019 |
|
|
|
# See bit.ly/seng468 for info |
|
|
|
# shellcheck disable=2162 |
|
true |
|
|
|
# customizeZSH adds some features to user's zsh configuration |
|
function customizeZsh { |
|
sed -i '$ d' "$HOME"/.zshrc && \ |
|
echo "## -------- Environment Variables --------------------------------------------------- ## |
|
|
|
# Get colours in man pages |
|
export LESS_TERMCAP_mb=$(printf "\e[1;31m") \ |
|
LESS_TERMCAP_md=$(printf "\e[1;31m") \ |
|
LESS_TERMCAP_me=$(printf "\e[0m") \ |
|
LESS_TERMCAP_se=$(printf "\e[0m") \ |
|
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ |
|
LESS_TERMCAP_ue=$(printf "\e[0m") \ |
|
LESS_TERMCAP_us=$(printf "\e[1;32m") |
|
|
|
\$GOPATH=\$HOME/go |
|
|
|
|
|
## -------- Aliases ---------------------------------------------------------------- ## |
|
|
|
# Graphical display of git log |
|
alias ggraph='git log --graph --oneline --decorate --color --all' |
|
|
|
|
|
## -------- Functions ---------------------------------------------------------------- ## |
|
|
|
# start a 1x3 tmux session |
|
dotmux() { |
|
NAME=\"dotmux-session\" |
|
tmux kill-session -t \"$NAME\" &> /dev/null |
|
tmux new-session -s \"$NAME\" -n \"$NAME\" -d |
|
tmux split-window -h -t \"$NAME\" |
|
tmux split-window -t \"$NAME\":0.1 -v -p 66 |
|
tmux split-window -t \"$NAME\":0.2 -v -p 50 |
|
tmux select-pane -t \"$NAME\":0.0 |
|
tmux attach -t \"$NAME\" |
|
} |
|
|
|
|
|
## -------- Functions ---------------------------------------------------------------- ## |
|
|
|
# hub - the command line wrapper for git |
|
eval "\$\(hub alias -s\)" |
|
fpath=(~/.zsh/completions \$fpath) |
|
autoload -U compinit && compinit" >> "$HOME"/.zshrc |
|
|
|
|
|
# TODO: build an array of lines to change from default, feed that to `sed -i` |
|
touch "$HOME"/.zpreztorc && |
|
truncate -s 0 "$HOME"/.zpreztorc && \ |
|
echo "## -------- General ---------------------------------------------------------------- ## |
|
|
|
# Set case-sensitivity for completion, history lookup, etc. |
|
# zstyle ':prezto:*:*' case-sensitive 'yes' |
|
|
|
# Color output (auto set to 'no' on dumb terminals). |
|
zstyle ':prezto:*:*' color 'yes' |
|
|
|
# Set the Prezto modules to load (browse modules). |
|
# The order matters. |
|
zstyle ':prezto:load' pmodule \\ |
|
'environment' \\ |
|
'terminal' \\ |
|
'editor' \\ |
|
'history' \\ |
|
'directory' \\ |
|
'spectrum' \\ |
|
'utility' \\ |
|
'ssh' \\ |
|
'completion' \\ |
|
'prompt' \\ |
|
'git' \\ |
|
'syntax-highlighting' \\ |
|
'history-substring-search' \\ |
|
'autosuggestions' |
|
|
|
# Set the key mapping style to 'emacs' or 'vi'. |
|
zstyle ':prezto:module:editor' key-bindings 'vi' |
|
|
|
# Auto convert .... to ../.. |
|
zstyle ':prezto:module:editor' dot-expansion 'yes' |
|
|
|
|
|
## -------- Git ---------------------------------------------------------------- ## |
|
|
|
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'. |
|
zstyle ':prezto:module:git:status:ignore' submodules 'all' |
|
|
|
|
|
## -------- History Substring Search ---------------------------------------------------------------- ## |
|
|
|
# Set the query found color. |
|
zstyle ':prezto:module:history-substring-search:color' found '' |
|
|
|
# Set the query not found color. |
|
zstyle ':prezto:module:history-substring-search:color' not-found '' |
|
|
|
# Set the search globbing flags. |
|
zstyle ':prezto:module:history-substring-search' globbing-flags '' |
|
|
|
|
|
## -------- Prompt ---------------------------------------------------------------- ## |
|
|
|
# Set the prompt theme to load. |
|
# Setting it to 'random' loads a random theme. |
|
# Auto set to 'off' on dumb terminals. |
|
zstyle ':prezto:module:prompt' theme 'sorin' |
|
|
|
|
|
## -------- SSH ---------------------------------------------------------------- ## |
|
|
|
# Set the SSH identities to load into the agent. |
|
zstyle ':prezto:module:ssh:load' identities 'id_rsa' |
|
|
|
|
|
## -------- Syntax Highlighting ---------------------------------------------------------------- ## |
|
|
|
# Set syntax highlighters. |
|
# By default, only the main highlighter is enabled. |
|
zstyle ':prezto:module:syntax-highlighting' highlighters \\ |
|
'main' \\ |
|
'brackets' \\ |
|
'pattern' \\ |
|
'cursor' \\ |
|
'root' |
|
|
|
# Set syntax highlighting styles. |
|
# zstyle ':prezto:module:syntax-highlighting' styles \\ |
|
# 'builtin' 'bg=blue' \\ |
|
# 'command' 'bg=blue' \\ |
|
# 'function' 'bg=blue' |
|
|
|
|
|
## -------- Terminal ---------------------------------------------------------------- ## |
|
|
|
# Auto set the tab and window titles. |
|
zstyle ':prezto:module:terminal' auto-title 'yes' |
|
|
|
# Set the window title format. |
|
zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s' |
|
|
|
# Set the tab title format. |
|
zstyle ':prezto:module:terminal:tab-title' format '%m: %s' |
|
|
|
# - fin -" >> "$HOME"/.zpreztorc |
|
} |
|
|
|
|
|
# customizeVim adds features to user's vim |
|
function customizeVim { |
|
touch "$HOME"/.vimrc && |
|
truncate -s 0 "$HOME"/.vimrc && \ |
|
echo "\" -------- Vim options & variables ------------------------------- |
|
|
|
set encoding=utf-8 \" UTF-8 |
|
set autoindent \" Auto-indent new lines |
|
set background=dark \" Use colors that look good on a dark background |
|
set expandtab \" Insert spaces instead of tabs |
|
set hlsearch \" Highlight all search results |
|
set ignorecase \" Always case-insensitive |
|
set incsearch \" Searches for strings incrementally |
|
set linebreak \" Break lines at word (requires wrap lines) |
|
set nocompatible \" Make Vim more useful |
|
set number \" Show line numbers |
|
set shiftwidth=4 \" Number of auto-indent spaces |
|
set showbreak=+++ \" Wrap-broken line prefix |
|
set showmatch \" Highlight matching brace |
|
set smartcase \" Enable smart-case search |
|
set smartindent \" Enable smart-indent |
|
set smarttab \" Enable smart-tabs |
|
set softtabstop=4 \" Number of spaces per tab |
|
set textwidth=82 \" Line wrap (number of columns) |
|
set visualbell \" Use visual bell (no beeping) |
|
|
|
let mapleader=\",\" \" Remap <leader> key to comma |
|
|
|
filetype plugin indent on \" Enable filetype-specific goodies |
|
|
|
syntax on \" Enable syntax highlighting |
|
|
|
|
|
\" -------- Key mappings -------------------------------------- |
|
|
|
inoremap jk <Esc> \" Use 'jk' to get out of INSERT mode |
|
inoremap kj <Esc> \" Use 'kj' to get out of INSERT mode |
|
|
|
nnoremap <C-J> <C-W><C-J> \" 'ctrl-j' instead of 'ctrl-w then j' |
|
nnoremap <C-K> <C-W><C-K> \" 'ctrl-k' instead of 'ctrl-w then k' |
|
nnoremap <C-L> <C-W><C-L> \" 'ctrl-l' instead of 'ctrl-w then l' |
|
nnoremap <C-H> <C-W><C-H> \" 'ctrl-h' instead of 'ctrl-w then h' |
|
|
|
|
|
\" -------- GUI config ---------------------------------------- |
|
|
|
if has(\"gui_running\") |
|
set guifont=Hasklig:h15 |
|
endif |
|
|
|
|
|
\" -------- junegunn/vim-plug --------------------------------- |
|
if empty(glob('~/.vim/autoload/plug.vim')) |
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ |
|
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |
|
autocmd VimEnter * PlugInstall --sync | source \$MYVIMRC |
|
endif |
|
|
|
call plug#begin('~/.vim/plugged') \" Specify a directory for plugins |
|
Plug 'airblade/vim-gitgutter' \" Shows a git diff in the gutter |
|
Plug 'edkolev/tmuxline.vim' \" Vim-Airline for tmux |
|
Plug 'scrooloose/nerdtree' \" File tree explorer |
|
Plug 'sheerun/vim-polyglot' \" Language pack for Vim |
|
Plug 'vim-airline/vim-airline' \" Vim-Airline status bar |
|
call plug#end() \" Initialize plugin system |
|
|
|
|
|
\" -------- airblade/vim-gitgutter -------------------------------- |
|
let g:gitgutter_max_signs = 500 \" Maximum number of lines to mark, default=500 |
|
|
|
\" -------- vim-airline/vim-airline ------------------------------- |
|
let g:airline_powerline_fonts = 1 |
|
|
|
\" - fin -" >> "$HOME"/.vimrc |
|
} |
|
|
|
# customizeTmux fills out the user's tmux config file |
|
function customizeTmux { |
|
touch "$HOME"/.tmux.conf && \ |
|
echo " |
|
# Allow mouse scrolling and pane selection |
|
set -g mouse on |
|
|
|
# 0 key is too far from 2,3,4... |
|
set -g base-index 1 |
|
|
|
# Reload tmux config |
|
bind r source-file ~/.tmux.conf |
|
" >> "$HOME"/.tmux.conf |
|
} |
|
|
|
read -n1 -p " |
|
We're about to set this machine up for systems development with Docker and Golang. |
|
You will be prompted for information several times during this process. |
|
You ready? [y/N]" letsGo |
|
case $letsGo in |
|
y|Y);; |
|
*) |
|
exit 0 |
|
;; |
|
esac |
|
|
|
echo " |
|
Fetching latest packages and installing git |
|
" |
|
sudo apt update && \ |
|
sudo apt install git curl |
|
|
|
echo " |
|
Enabling coloured UI |
|
" |
|
git config --global color.ui auto |
|
|
|
echo " |
|
Using system cache to reduce user/pass entry fatigue |
|
" |
|
git config --global credential.helper cache |
|
|
|
echo " |
|
Setting VSCode as default editor |
|
" |
|
git config --global core.editor "code --wait" |
|
|
|
read -p "GIT: Enter your full name for git, eg. \"Bill Gates\": " gitUserFullName |
|
git config --global user.name "$gitUserFullName" |
|
|
|
read -p "GIT: Enter your email for git, eg. \"[email protected]\": " gitUserEmail |
|
git config --global user.email "$gitUserEmail" |
|
|
|
read -n1 -p " |
|
Do you want to configure git to automatically push a new local branch to a new remote branch of the same name? |
|
This would prevent you from having to add \"--set-upstream origin <branch-name>\" every time [y/N] |
|
" gitPushMode |
|
|
|
case $gitPushMode in |
|
y|Y) |
|
git config --global push.default current |
|
;; |
|
*) |
|
git config --global push.default simple |
|
;; |
|
esac |
|
|
|
echo " |
|
Git configuration saved: |
|
" |
|
git config --global -l |
|
echo |
|
|
|
echo " |
|
Cloning project repositories... |
|
" |
|
|
|
read -p "Please enter your GitHub username: " githubUsername |
|
|
|
read -p "Please enter your GitHub password: " githubPassword |
|
|
|
git clone -v https://$githubUsername:[email protected]/dukeng/SENG-468-Logging-Server.git Logging-Server |
|
git clone -v https://$githubUsername:[email protected]/dukeng/SENG-468-Workload-Generator.git Workload-Generator |
|
git clone -v https://$githubUsername:[email protected]/kurtd5105/SENG-468-Common-Lib.git Common-Lib |
|
git clone -v https://$githubUsername:[email protected]/kurtd5105/SENG-468-Transaction-Server.git Transaction-Server |
|
git clone -v https://$githubUsername:[email protected]/sterlinglaird/SENG-468-Database-Server.git Database-Server |
|
git clone -v https://$githubUsername:[email protected]/sterlinglaird/SENG-468-Quote-Server.git Quote-Server |
|
git clone -v https://$githubUsername:[email protected]/stvhwrd/SENG-468-HTTP-Server.git HTTP-Server |
|
|
|
|
|
echo " |
|
Installing some nice-to-have utilities... |
|
" |
|
sudo apt install -y curl screenfetch figlet htop tree xclip zip unzip snapd |
|
|
|
|
|
echo " |
|
Installing Go |
|
" |
|
mkdir -p "$HOME"/go |
|
sudo apt install -y golang |
|
|
|
|
|
## -------- git ---------------------------------------------------------------- ## |
|
|
|
echo " |
|
Installing git LFS... |
|
" |
|
sudo apt install -y build-essential libssl-dev software-properties-common apt-transport-https wget git && \ |
|
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \ |
|
sudo apt update && \ |
|
sudo apt install -y git-lfs && \ |
|
git lfs install |
|
|
|
echo " |
|
Installing hub, the command-line wrapper for for git... |
|
" |
|
|
|
export GOPATH="$HOME"/go |
|
mkdir -p "$GOPATH"/src/github.com/github && \ |
|
git clone \ |
|
--config transfer.fsckobjects=false \ |
|
--config receive.fsckobjects=false \ |
|
--config fetch.fsckobjects=false \ |
|
https://github.com/github/hub.git "$GOPATH"/src/github.com/github/hub && \ |
|
cd "$GOPATH"/src/github.com/github/hub && \ |
|
make install prefix=/usr/local |
|
|
|
## -------- apt ---------------------------------------------------------------- ## |
|
|
|
echo " |
|
APT: Installing Docker |
|
" |
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \ |
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" && \ |
|
sudo apt update && \ |
|
apt-cache policy docker-ce && \ |
|
sudo apt install -y docker-ce |
|
|
|
echo " |
|
APT: Installing Docker Compose |
|
" |
|
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Linux-x86_64" \ |
|
-o /usr/local/bin/docker-compose && \ |
|
sudo chmod +x /usr/local/bin/docker-compose |
|
|
|
echo " |
|
APT: Installing and setting up terminal multiplexer... |
|
" |
|
sudo apt install -y tmux |
|
customizeTmux |
|
|
|
echo " |
|
APT: Installing and setting up vim... |
|
" |
|
sudo apt install -y vim |
|
customizeVim |
|
|
|
echo " |
|
APT: Installing Visual Studio Code... |
|
" |
|
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - && \ |
|
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" && \ |
|
sudo apt install -y code && \ |
|
code --install-extension ms-vscode.Go && \ |
|
code --install-extension PeterJausovec.vscode-docker && \ |
|
code --install-extension formulahendry.auto-close-tag |
|
|
|
echo " |
|
APT: Installing Sublime Text... |
|
" |
|
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - %% \ |
|
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list && \ |
|
sudo apt update && \ |
|
sudo apt install -y sublime-text |
|
|
|
echo " |
|
APT: Installing Hasklig font... |
|
" |
|
mkdir ~/.fonts && \ |
|
wget --no-check-certificate https://github.com/i-tu/Hasklig/releases/download/1.1/Hasklig-1.1.zip -P /tmp && \ |
|
unzip Hasklig-1.1.zip -d /tmp/Hasklig && \ |
|
cp /tmp/Hasklig/*.otf ~/.fonts && \ |
|
fc-cache -f -v |
|
|
|
|
|
## -------- zsh ---------------------------------------------------------------- ## |
|
|
|
echo " |
|
ZSH: Installing zsh and Prezto... |
|
" |
|
rm -rf "${ZDOTDIR:-$HOME}/.zprezto" && \ |
|
sudo apt install -y zsh && \ |
|
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" && \ |
|
|
|
/bin/zsh -c "setopt EXTENDED_GLOB && \ |
|
for rcfile in \"\${ZDOTDIR:-\$HOME}\"/.zprezto/runcoms/^README.md(.N); do |
|
ln -s \"\$rcfile\" \"\${ZDOTDIR:-\$HOME}/.\${rcfile:t}\"; |
|
done" && \ |
|
|
|
echo " |
|
ZSH: Changing default shell to zsh |
|
" |
|
sudo chsh -s /bin/zsh |
|
|
|
echo " |
|
ZSH: Adding customizations... |
|
" |
|
customizeZsh |
|
|
|
|
|
## -------- Desktop environments ---------------------------------------------------------------- ## |
|
|
|
read -p " |
|
OS: Do you want to install an alternative desktop environment? |
|
(This may take 10+ minutes) |
|
---> " altDE |
|
|
|
case $altDE in |
|
y|Y) |
|
read -p -n1" |
|
Choose an option: |
|
|
|
[1] XFCE -- like Xubuntu |
|
[2] Pantheon -- like elementary OS |
|
[3] Both -- both XFCE and Pantheon |
|
[*] Neither -- no change |
|
|
|
---> " chosenDE |
|
case $chosenDE in |
|
1) |
|
echo " |
|
Installing elementary OS desktop environment |
|
" |
|
sudo add-apt-repository ppa:elementary-os/stable |
|
sudo apt update |
|
sudo apt install -y elementary-desktop |
|
;; |
|
2) |
|
echo " |
|
Installing XFCE desktop environment |
|
" |
|
sudo apt -y install tasksel |
|
sudo tasksel install xubuntu-desktop |
|
;; |
|
3) |
|
echo " |
|
Installing both XFCE and elementary OS desktop environments |
|
" |
|
sudo add-apt-repository ppa:elementary-os/stable |
|
sudo apt update |
|
sudo apt install -y tasksel |
|
sudo tasksel install xubuntu-desktop |
|
sudo apt install -y elementary-desktop |
|
;; |
|
*);; |
|
esac |
|
;; |
|
*) |
|
echo " |
|
Skipping new desktop environment installation |
|
" |
|
;; |
|
esac |
|
|
|
echo " |
|
All installations complete. Reboot the machine and bask in the glory of your new dev box. |
|
" |
|
|
|
read -p " |
|
Reboot now? [y/N] |
|
" rebootOrNah |
|
case $rebootOrNah in |
|
y|Y) |
|
sudo reboot |
|
;; |
|
*) |
|
exit 0 |
|
;; |
|
esac |