Skip to content

Instantly share code, notes, and snippets.

@engineervix
Last active May 1, 2024 07:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engineervix/fea927d193b6fc767337a56d176e9797 to your computer and use it in GitHub Desktop.
Save engineervix/fea927d193b6fc767337a56d176e9797 to your computer and use it in GitHub Desktop.
Ubuntu Desktop Setup
#!/usr/bin/env bash
# =============================================================================
# description: Ubuntu 22.04 Desktop Setup Script
# author: Victor Miti <https://github.com/engineervix>
# note: In its current state, this won't run unattended without issues.
# There are some manual interventions in between certain steps.
# The script primarily serves as documentation of the setup process
# for future reference.
# TODO: make this run unattended.
#
# =============================================================================
# 0. Update System and Repositories
sudo apt update && sudo apt upgrade -y
# 1. Hardware / Performance
## Optimize laptop battery life
sudo apt install tlp tlp-rdw -y
sudo systemctl enable tlp
# 2. git & curl
sudo apt install git curl -y
# 3. Dev tools and other important dependencies
sudo apt-get install apt-transport-https -y
sudo apt-get install --no-install-recommends make net-tools build-essential libssl-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libxml2-dev libxmlsec1-dev liblzma-dev clang -y
sudo apt install gdebi -y
# 4. Node
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
## NOTE: probably better to install volta and friends after installing and setting ZSH as default shell
curl https://get.volta.sh | bash
exec $SHELL
volta install node@18
npm install -g commitizen
npm install -g doctoc
npm install -g html-minifier
npm install -g lite-server
npm install -g prettier
npm install -g serve
npm install -g standard-version
npm install -g svgo
npm install -g mdpdf
npm install -g mozjpeg
npm install -g npm-check
# 5. Yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn -y
# 6. Python
# also installs python3-dev
sudo apt-get install -y python3-pip
# PILLOW dependencies
sudo apt-get install libffi-dev libjpeg-dev libtiff-dev libfreetype6-dev libraqm-dev pngquant tk-dev libwebp-dev liblcms2-dev -y
# 7. Sublime text
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text -y
# TODO: Install package control and the following packages:
## - Djaneiro
## - Dockerfile Syntax Highlighting
## - DotENV
## - Emmet
## - Jinja
## - Markdown Extended
## - Monokai Extended
## - Nunjucks
## - requirementstxt
## - Rust Enhanced
## - SCSS
## - TOML
## - Vue Syntax Highlight
# 8. Google Chrome, Brave
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo gdebi --non-interactive ./google-chrome-stable_current_amd64.deb
rm -fv google-chrome-stable_current_amd64.deb
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"|sudo tee /etc/apt/sources.list.d/brave-browser-release.list
sudo apt update
sudo apt install brave-browser -y
# 9. ZSH
sudo apt-get install zsh -y
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
bash -c "sed 's/robbyrussell/powerlevel10k\/powerlevel10k/g' -i ~/.zshrc"
sudo apt install fonts-inconsolata fonts-symbola -y
sudo apt install fonts-powerline -y
wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf
wget https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
sudo mv -v PowerlineSymbols.otf /usr/share/fonts/
sudo mv -v MesloLGS*.ttf /usr/share/fonts/
sudo fc-cache -vf
sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# TODO: manually update your .zshrc config.
# See <https://raw.githubusercontent.com/engineervix/ubuntu-server-setup/v1.4.0/configuration_files/.zshrc> or
# <https://github.com/engineervix/pre-dokku-server-setup/blob/v0.1.0/extras/.zshrc> for reference
sudo -i -u "${USER}" -H bash -c "chsh -s $(which zsh)"
# 10. Virtualenvwrapper
sudo -H pip3 install virtualenvwrapper
export WORKON_HOME="/home/$USER/Env"
mkdir -p "$WORKON_HOME"
echo "" >> ~/.zshrc
echo "# virtualenvwrapper" >> ~/.zshrc
echo "export WORKON_HOME=~/Env" >> ~/.zshrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.zshrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.zshrc
echo "" >> ~/.zshrc
# 11. Pyenv
curl https://pyenv.run | bash
# TODO: check your pyenv config, then install the python versions you need
## pyenv install 3.6.15
## pyenv install 3.7.16
## pyenv install 3.8.16
## pyenv install 3.9.16
## pyenv install 3.11.2
## 12. Poetry
curl -sSL https://install.python-poetry.org | python3 -
mkdir -p $ZSH_CUSTOM/plugins/poetry
poetry completions zsh > $ZSH_CUSTOM/plugins/poetry/_poetry
# 13. Vim
sudo -H pip3 install powerline-status
sudo apt-get install vim-nox -y
# the Janus vim distribution uses `rake` for the setup
sudo apt-get install ruby-full ruby-bundler -y
curl -L https://bit.ly/janus-bootstrap | bash
curl -LJO https://raw.githubusercontent.com/engineervix/pre-dokku-server-setup/v0.1.0/extras/.vimrc.after --output-dir $HOME/
git clone --recurse-submodules https://github.com/engineervix/pre-dokku-server-setup.git \
&& cd pre-dokku-server-setup \
&& mv -v .janus/ $HOME/ \
&& cd .. \
&& rm -rfv pre-dokku-server-setup
cd $HOME/.vim/janus/vim/tools/tlib/plugin/ \
&& git pull origin master \
&& cd -
# 14. Tmux
sudo apt install tmux powerline -y
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
curl -LJO https://raw.githubusercontent.com/engineervix/ubuntu-server-setup/v1.4.0/configuration_files/.tmux.conf --output-dir $HOME/
# 15. Docker
if [ $(dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
sudo apt install ca-certificates -y;
fi
if [ $(dpkg-query -W -f='${Status}' software-properties-common 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
sudo apt install software-properties-common -y;
fi
if [ $(dpkg-query -W -f='${Status}' lsb-release 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
sudo apt install lsb-release -y;
fi
sudo apt remove --yes docker docker-engine docker.io containerd runc || true
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository --yes "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release --codename --short) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker "$USER"
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# 16. ufw
sudo ufw enable
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo wget -O /usr/local/bin/ufw-docker https://github.com/chaifeng/ufw-docker/raw/master/ufw-docker
sudo chmod +x /usr/local/bin/ufw-docker
sudo ufw-docker install
sudo systemctl restart ufw
sudo ufw status verbose
# 17. Miscellaneous
sudo apt-get install wkhtmltopdf ffmpeg -y
sudo apt install openjdk-8-jdk postgresql-client postgresql libpq-dev libtool libyaml-dev -y
sudo apt install hunspell pandoc dos2unix poppler-utils ncdu powertop htop shellcheck htop -y
sudo apt install imagemagick -y
sudo apt install ssh-askpass -y
sudo apt install gnome-control-center -y
sudo apt install gnome-shell-extensions -y
sudo apt install chrome-gnome-shell -y
sudo apt install dconf-editor -y
sudo apt install id3v2 sox mp3gain streamripper -y
sudo apt install plocate -y
sudo snap install pdftk
# 18. GUI tools
sudo apt install inkscape -y
sudo apt install audacity -y
sudo apt install gimp -y
sudo apt install vlc clementine -y
sudo apt install peek -y
sudo apt install meld -y
sudo apt install xournalpp -y
sudo snap install spectacle
sudo apt-get install thunar -y
sudo apt-get install pavucontrol -y
# TODO: Configure Spectacle so that it's activated by the Print Screen key
# 19. VS Code
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt update
sudo apt install code -y
curl -LJO https://gist.githubusercontent.com/engineervix/733ce0834fb288bc0f7bbca347470a20/raw/31c4c6f3b0e75d7d126d03c21aac5849d004bf0d/vscode-extensions.list
cat vscode-extensions.list | xargs -L 1 code --install-extension
rm -rfv vscode-extensions.list
# TODO: Configure VS Code (preferences, terminal, settings, extensions, etc.)
# 20. Zoom
wget https://zoom.us/client/latest/zoom_amd64.deb
sudo gdebi --non-interactive ./zoom_amd64.deb
rm -fv zoom_amd64.deb
# 21. Slack
wget https://downloads.slack-edge.com/releases/linux/4.33.73/prod/x64/slack-desktop-4.33.73-amd64.deb
sudo gdebi --non-interactive ./slack-desktop-*.deb
rm -fv slack-desktop-*.deb
# 22. Spotify
curl -sS https://download.spotify.com/debian/pubkey_7A3A762FAFD4A51F.gpg | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/spotify.gpg
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 -y
# 23. Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# 24. AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version
rm -v awscliv2.zip
rm -rv aws/
# 25. Heroku CLI
curl https://cli-assets.heroku.com/install.sh | sh
# 26. Some custom scripts / tools
mkdir -p $HOME/bin/
curl -LJO https://raw.githubusercontent.com/engineervix/pre-dokku-server-setup/v0.1.0/extras/shrinkpdf --output-dir $HOME/bin/
chmod +x $HOME/bin/shrinkpdf
# 27. rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
echo "" >> ~/.zshrc
echo "# rbenv" >> ~/.zshrc
echo 'eval "$(~/.rbenv/bin/rbenv init - zsh)"' >> ~/.zshrc
echo "" >> ~/.zshrc
rbenv install 3.2.2
rbenv global 3.2.2
# 28. colorls
gem install colorls
echo "" >> ~/.zshrc
echo "# colorls" >> ~/.zshrc
echo 'source $(dirname $(gem which colorls))/tab_complete.sh' >> ~/.zshrc
echo 'if [ -x "$(command -v colorls)" ]; then' >> ~/.zshrc
echo ' alias ls="colorls"' >> ~/.zshrc
echo ' alias la="colorls -alh"' >> ~/.zshrc
echo 'fi' >> ~/.zshrc
echo "" >> ~/.zshrc
# 29. Texlive (it's the last thing because it takes a while)
sudo apt install texlive-full -y
# TODO
## disable wayland by editing the file below and restarting
# sudo vim /etc/gdm3/custom.conf
## - [ ] configure ssh
# ssh-add ~/.ssh/filename
## - [ ] configure GPG
## - [ ] configure git
# git config --global color.ui true
# git config --global user.name "Your Name"
# git config --global user.email "email@address.com"
# git config --global commit.gpgsign true
# git config --global user.signingkey GNUGPGSIGNKEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment