Skip to content

Instantly share code, notes, and snippets.

@rojas-diego
Last active July 27, 2022 00:09
Show Gist options
  • Save rojas-diego/64067bc7020f07e5f65793f5d32858cd to your computer and use it in GitHub Desktop.
Save rojas-diego/64067bc7020f07e5f65793f5d32858cd to your computer and use it in GitHub Desktop.
Ubuntu Install Script
#!/bin/bash
mkdir -p $HOME/diego-install
cd $HOME/diego-install
# Installing utilities
echo "--------------------------------------------------------------------"
echo "> Updating apt"
sudo apt update
echo "--------------------------------------------------------------------"
echo "> Installing utilities (curl, wget, git)"
sudo apt install curl wget git zsh vim neovim gcc g++ make valgrind python3-pip python3-venv cmake libsfml-dev
# Google chrome
if ! command -v google-chrome-stable &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing google-chrome-stable..."
wget "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
sudo apt install "./google-chrome-stable_current_amd64.deb"
rm "./google-chrome-stable_current_amd64.deb"
else
echo "--------------------------------------------------------------------"
echo "> Skipping chrome..."
fi
# ZSH
if ! command -v zsh &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing oh-my-zsh..."
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
else
echo "--------------------------------------------------------------------"
echo "> Skipping oh-my-zsh..."
fi
# VSCode
if ! command -v code &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing vscode..."
wget https://code.visualstudio.com/sha/download\?build\=stable\&os\=linux-deb-x64 -O vscode.deb
sudo apt install "./vscode.deb"
rm "./vscode.deb"
else
echo "--------------------------------------------------------------------"
echo "> Skipping vscode..."
fi
# Docker
if ! command -v docker &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
sudo systemctl enable docker
else
echo "--------------------------------------------------------------------"
echo "> Skipping docker..."
fi
# Docker-Compose
if ! command -v docker-compose &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing docker-compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
else
echo "--------------------------------------------------------------------"
echo "> Skipping docker-compose..."
fi
# Discord
if ! command -v discord &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing discord..."
wget -O discord.deb "https://discordapp.com/api/download?platform=linux&format=deb"
sudo apt install "./discord.deb"
else
echo "--------------------------------------------------------------------"
echo "> Skipping discord..."
fi
# Spotify
if ! command -v spotify &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing spotify..."
curl -sS https://download.spotify.com/debian/pubkey_0D811D58.gpg | sudo apt-key add -
echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
sudo apt-get update && sudo apt-get install spotify-client
else
echo "--------------------------------------------------------------------"
echo "> Skipping spotify..."
fi
# Typora
if ! command -v typora &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing typora..."
wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -
sudo add-apt-repository 'deb https://typora.io/linux ./'
sudo apt-get update
sudo apt-get install typora
else
echo "--------------------------------------------------------------------"
echo "> Skipping typora..."
fi
# NVM
if ! test -d ~/.nvm
then
echo "--------------------------------------------------------------------"
echo "> Installing NVM..."
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | zsh
nvm install --lts
else
echo "--------------------------------------------------------------------"
echo "> Skipping NVM..."
fi
# Rust
if ! test -d ~/.cargo
then
echo "--------------------------------------------------------------------"
echo "> Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
else
echo "--------------------------------------------------------------------"
echo "> Skipping Rust..."
fi
# Golang
if ! command -v go &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing Golang..."
wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.16.2.linux-amd64.tar.gz
echo -ne '\nPATH=$PATH:/usr/local/go/bin\n' >> ~/.profile
echo -ne '\n# Golang path\nexport GOPATH=path/to/your/gopath/directory\n' >> ~/.zshrc
else
echo "--------------------------------------------------------------------"
echo "> Skipping Golang..."
fi
# Neovim
if ! command -v go &> /dev/null
then
echo "--------------------------------------------------------------------"
echo "> Installing Golang..."
wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.16.2.linux-amd64.tar.gz
echo -ne '\nPATH=$PATH:/usr/local/go/bin\n' >> ~/.profile
echo -ne '\n# Golang path\nexport GOPATH=path/to/your/gopath/directory\n' >> ~/.zshrc
else
echo "--------------------------------------------------------------------"
echo "> Skipping Golang..."
fi
rm -rf $HOME/diego-install
echo "--------------------------------------------------------------------"
echo "Final notes:"
echo "- Add docker and docker-compose plugins inside the .zshrc"
echo "- Add ssh key"
echo "- Add vscode settings"
local pstatus="%{$fg_bold[green]%}$%{$reset_color%}"
local ptime="%{$fg[grey]%}%t%{$reset_color%}"
local pcwd="%{$fg[blue]%}./%c%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[gray]%}:%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
PROMPT=' ${pstatus} ${pcwd}$(git_prompt_info)$(git_time_since_commit) -${ptime} '
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function git_time_since_commit() {
if git rev-parse --git-dir > /dev/null 2>&1; then
# Only proceed if there is actually a commit.
if git log -n 1 > /dev/null 2>&1; then
# Get the last commit.
last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
now=`date +%s`
seconds_since_last_commit=$((now-last_commit))
# Totals
MINUTES=$((seconds_since_last_commit / 60))
HOURS=$((seconds_since_last_commit/3600))
# Sub-hours and sub-minutes
DAYS=$((seconds_since_last_commit / 86400))
SUB_HOURS=$((HOURS % 24))
SUB_MINUTES=$((MINUTES % 60))
COLOR="%{$fg[grey]%}"
if [ "$HOURS" -gt 24 ]; then
echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%})"
elif [ "$MINUTES" -gt 60 ]; then
echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%})"
else
echo "($COLOR${MINUTES}m%{$reset_color%})"
fi
else
echo "()"
fi
fi
}
{
"window.zoomLevel": 1,
"workbench.tree.indent": 24,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"debug.console.fontSize": 16,
"editor.fontSize": 17,
"git.autofetch": true,
"files.trimTrailingWhitespace": true,
"files.exclude": {
"**/*.o": true,
"**/*.gcda": true,
"**/*.gcno": true
},
"explorer.confirmDragAndDrop": false,
"editor.fontFamily": "Ubuntu Mono",
"terminal.integrated.rendererType": "dom",
"window.titleBarStyle": "native",
"workbench.editor.tabCloseButton": "left",
"workbench.editor.showIcons": true,
"workbench.sideBar.location": "left",
"editor.renderLineHighlight": "all",
"editor.minimap.enabled": false,
"editor.renderIndentGuides": true,
"editor.selectionHighlight": false,
"files.insertFinalNewline": true,
"editor.suggestSelection": "first",
"editor.rulers": [
80
],
"editor.wordWrapColumn": 80,
"gitlens.codeLens.authors.enabled": false,
"gitlens.codeLens.recentChange.enabled": false,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment