Skip to content

Instantly share code, notes, and snippets.

@felipepodesta
Forked from abd6982/README.md
Created June 2, 2021 04:06
Show Gist options
  • Save felipepodesta/fd5a9b89a36895dd0d27de87b36e2bf0 to your computer and use it in GitHub Desktop.
Save felipepodesta/fd5a9b89a36895dd0d27de87b36e2bf0 to your computer and use it in GitHub Desktop.
Ubuntu Development Environment Setup Script

Ubuntu Dev Setup Script

I tend to setup and teardown my dev environments quite frequently. So I have created this setup.sh script to automate setting up the dev environment with my preferences.

This script -

  • Installs curl, git, net-tools, and tree.
  • Installs build-essential package which installs gcc, g++ and some other libs.
  • Installs the latest openjdk and maven.
  • Installs python3 and some required libraries (I use them pretty often).
  • Installs nodejs 12 globally. Then installs Node Version Manager and installs all LTS versions.
  • Installs docker and docker-compose
  • Installs zsh and oh-my-zsh and powerline fonts, and changes theme to agnoster.

The script has been tested on Ubuntu 20.04 (standalone and WSL2).

Prerequisites

  • Make sure Windows 10 is updated to May 2020 Update (ver 2004)
  • Open the Turn Windows features on or off utility. Enable -
    • Virtual Machine Platform
    • Windows Hypervisor Platform
    • Windows Subsystem for Linux
  • Restart Windows to enable above features.
  • Go to this link. Download and install WSL2 kernel.
  • Open powershell and execute wsl --set-default-version 2 to set v2 as the default WSL2 version.
  • Go to Microsoft Store and install a distribution of your choice (Ubuntu, Debian, etc). Optionally install Windows Terminal.

Visual Studio Code

Add this line in the settings.json file in VSCode

"terminal.integrated.fontFamily": "'Cascadia Mono PL'"

Making agnoster work in WSL (using Windows Terminal)

To make agnoster show all the glyphs properly in WSL, some additional steps are required.

  1. Download and install the latest Cascadia Code.
  2. In your profiles.json, change the fontFace property to Cascadia Code PL (or whichever variant you like).

So, your favorite WSL distro's settings will look something like

{
    "guid": "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}",
    "name": "Ubuntu 20.04 LTS",
    "source": "Windows.Terminal.Wsl",
    "commandline": "wsl.exe -d Ubuntu-20.04",
    "fontFace": "Cascadia Code PL",
    "fontSize": 12,
}

NOTE: If you like to use the terminal provided by your favorite distro, then go to it's properties (right-click on title bar and click on properties), go to the Fonts tab, and select Cascadia Mono PL.

Extras

  1. This issue in the agnoster-zsh-theme repo consists of some really cool zsh prompts.
  2. atomcorp.github.io/themes/ has a bunch of really cool themes for Windows Terminal.
  3. To open any folder/repo in VSCode, just go to the folder on terminal and execute code .. This will perform a one time setup where it installs the remote VSCode server in your distro.
  4. To run linux GUI apps, install and run VcXsrv, then go to the Running Graphical Applications sub-section in the WSL Ubuntu Wiki and follow the steps there.
#!/bin/bash
set -u
set -e
set -o pipefail
# Define color variables.
RESTORE=$(echo -en '\033[0m')
RED=$(echo -en '\033[00;31m')
GREEN=$(echo -en '\033[00;32m')
YELLOW=$(echo -en '\033[00;33m')
# Check if arguments were passed. This script expects a non-root user to be supplied.
if [ $# -eq 0 ]
then
echo -e "\n${RED}Non root user not specified. Exiting!!!${RESTORE}"
exit 1
fi
USER=$1
# Check if the supplied user exists.
id -u $USER
SEP="##################################################"
echo -e "\n${GREEN}${SEP}\n -> UPDATING PACKAGES\n${SEP}${RESTORE}\n"
sudo apt-get update && sudo apt-get upgrade -y
echo -e "\n${GREEN}${SEP}\n -> INSTALLING ESSENTIAL TOOLS\n${SEP}${RESTORE}\n"
sudo apt-get install curl git net-tools tree unzip -y
echo -e "\n${GREEN}${SEP}\n -> SETTING UP C/C++/GOLANG ENVIRONMENT\n${SEP}${RESTORE}\n"
sudo apt-get install build-essential golang -y
echo -e "\n${GREEN}${SEP}\n -> SETTING UP JAVA ENVIRONMENT\n${SEP}${RESTORE}\n"
sudo apt-get install default-jdk maven -y
echo -e "\n${GREEN}${SEP}\n -> SETTING UP PYTHON ENVIRONMENT\n${SEP}${RESTORE}\n"
sudo apt-get install python3 python3-pip python3-venv python3-virtualenv -y
echo -e "\n${GREEN}${SEP}\n -> SETTING UP NODE ENVIRONMENT\n${SEP}${RESTORE}\n"
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo -u $USER bash -c '\
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> ~/.bashrc
source ~/.nvm/nvm.sh
nvm install v6.17.1 && nvm install v8.17.0 && nvm install v10.21.0 && nvm install v12.18.0
nvm alias default v10.21.0
'
echo -e "\n${GREEN}${SEP}\n -> INSTALLING DOCKER & DOCKER-COMPOSE\n${SEP}${RESTORE}\n"
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
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 $(lsb_release -cs) stable"
sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo -e "\n${GREEN}${SEP}\n -> SETTING UP ZSH\n${SEP}${RESTORE}\n"
sudo apt-get install zsh -y
sudo -u $USER bash -c '\
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
chsh -s $(which zsh)
sudo apt-get install fonts-powerline -y
git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
sed -i '0,/robbyrussell/s//agnoster/' ~/.zshrc
sed -i '\''/ZSH_THEME="agnoster"/a export NVM_LAZY_LOAD=true'\'' ~/.zshrc
sed -i '\''/export NVM_LAZY_LOAD=true/a export NVM_COMPLETION=true'\'' ~/.zshrc
sed -i '\'':a;$!{N;ba};s/git/'\''"git python zsh-nvm docker docker-compose dotenv jsontools"'\''/3'\'' ~/.zshrc
echo "prompt_context() { prompt_segment black default \"%(!.%{%F{yellow}%}.)\$USER\" }" >> ~/.zshrc
'
echo -e "\n${GREEN}${SEP}\n -> COMPLETE. PLEASE RESTART YOUR TERMINAL SESSION!\n${SEP}${RESTORE}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment