Skip to content

Instantly share code, notes, and snippets.

@DaniGuardiola
Last active July 31, 2020 11:11
Show Gist options
  • Save DaniGuardiola/def024b7571e8cda4d2043cf50872e1e to your computer and use it in GitHub Desktop.
Save DaniGuardiola/def024b7571e8cda4d2043cf50872e1e to your computer and use it in GitHub Desktop.
Pop! OS: personal after-install setup script | execution: $ source <(wget -qO - pop-os.daniguardiola.me)
# NOTE: you can comment out any components you don't need
# but DO NOT change the order of the scripts
# development software
./vscode.sh # DO NOT COMMENT THIS LINE OR THE SCRIPT WILL CRASH! I'm working on a fix, sorry.
./tools.sh
./hyper.sh
./docker.sh
./python.sh
./rust.sh
./node.sh
./go.sh
# UX and graphic design software
./pencil.sh
# appearance
./cool-prompt.sh
./gnome.sh
# other software
./google-chrome.sh
./discord.sh
./telegram.sh
./vlc.sh
./webtorrent.sh
./steam.sh
./lutris.sh
./transmission.sh
./mega.sh
# manual configurations
# (requires user input)
./git-config.sh
./ssh-config.sh
# load script utils
source script-utils.sh
# install prompt
bashrc cool-prompt "
case \"\$TERM\" in
\n xterm-color|*-256color) color_prompt=yes;;
\nesac
\n
\nif [ -n \"\$force_color_prompt\" ]; then
\n if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
\n color_prompt=yes
\n else
\n color_prompt=
\n fi
\nfi
\n
\nparse_git_branch() {
\n git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/ \\1 /'
\n}
\nif [ \"\$color_prompt\" = yes ]; then
\n PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\033[01;32m\\]\\u \\[\\033[01;34m\\]\\w\\[\\033[01;31m\\]\$(parse_git_branch)\\[\\033[00m\\]\\\$ '
\nelse
\n PS1='\${debian_chroot:+(\$debian_chroot)}\\u@\\h:\\w\$(parse_git_branch)\\\$ '
\nfi
\nunset color_prompt force_color_prompt"
# load script utils
source script-utils.sh
log 'Installing Discord'
exit-if-installed discord
flatpak install --noninteractive flathub com.discordapp.Discord
# load script utils
source script-utils.sh
log 'Installing docker'
exit-if-installed docker
sudo apt install docker.io -y
sudo groupadd docker
sudo usermod -aG docker $USER
log 'Installing docker-compose'
sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# About
# -----
# This is a set of scripts that help me set up my Pop! OS machine
# with development tools, some configurations and some other software
# (for example, steam and discord are included).
# Of course, the components included in the script are the ones that I
# personally make use of, but it should be useful for anyone who wants
# to easily install / configure a subset (or all) of these components.
# The downloader script (this one) is designed for ease of use and allows
# optional customization of the components to install / configure.
# This should work for any recent version of Pop! OS above 20.04, but the last time
# I tested it I was on 20.04. It also works with a fresh install, with
# no pre-requisites.
# Oh, and one last thing, these scripts are idempotent, so you can
# execute them multiple times and things won't break, nor your
# .bashrc file will grow indefinitely.
# Enjoy! :)
# Usage
# -----
# Method 1 (simplest, recommended)
# Use the downloader:
# $ source <(wget -qO - pop-os.daniguardiola.me)
# Method 2 (advanced)
# 1. Download this gist as ZIP and extract it
# URL: https://gist.github.com/DaniGuardiola/def024b7571e8cda4d2043cf50872e1e/
# 2. $ cd <path>/pop-os-setup/
# 3. (optional) Edit the components and configurations sections in components.sh
# 4. $ sudo chmod +x pop-os-setup.sh
# 5. $ ./pop-os-setup.sh
echo -e "\nWelcome to the Pop! OS setup script by Dani Guardiola"
echo -e "-----------------------------------------------------\n"
echo -e "Source code: https://gist.github.com/DaniGuardiola/def024b7571e8cda4d2043cf50872e1e/"
echo -e "Instructions: http://pop-os.daniguardiola.me/\n\n"
read -p "Press enter to proceed (or ctrl + c to abort)..."
echo
# sudo cache
sudo echo
echo -e "\n> Downloading Pop! OS install scripts...\n"
cd /tmp
rm -rf pop-os-setup pop-os-setup.zip
wget -O pop-os-setup.zip https://codeload.github.com/gist/def024b7571e8cda4d2043cf50872e1e/zip/master
unzip -q -d pop-os-setup/ -j pop-os-setup.zip
cd pop-os-setup/
sudo chmod +x pop-os-setup.sh
read -p "Do you want to customize the components to install? y/n " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e "\nAn editor will be opened with the component list file. Edit it,"
echo -e "save the file and close the editor to continue.\n"
read -p "Press enter to proceed (or ctrl + c to abort)..."
echo -e "\nWaiting for editor to be closed..."
gedit components.sh
fi
echo -e "\n\n> Executing Pop! OS install scripts..."
./pop-os-setup.sh
# load ~/.bashrc
source ~/.bashrc
# load script utils
source script-utils.sh
log 'Configuring git'
read -p 'What name do you want to use with git? ' GIT_NAME
read -p 'What email do you want to use with git? ' GIT_EMAIL
git config --global user.email $GIT_EMAIL
git config --global user.name $GIT_NAME
git config --global push.default simple
# load script utils
source script-utils.sh
log 'Installing Gnome tweaks'
sudo apt install gnome-tweaks -y
log 'Installing Gnome extension installer scripts'
sudo wget -O /usr/bin/gnome-shell-extension-installer "https://github.com/brunelli/gnome-shell-extension-installer/raw/master/gnome-shell-extension-installer"
sudo chmod +x /usr/bin/gnome-shell-extension-installer
log 'Installing some Gnome extensions'
gnome-shell-extension-installer 906 1112 7 1476 800 943 1116 1473 1459 744 352 --yes --restart-shell
# INSTALLED:
# - https://extensions.gnome.org/extension/906/sound-output-device-chooser/
# - https://extensions.gnome.org/extension/1112/screenshot-tool/
# - https://extensions.gnome.org/extension/7/removable-drive-menu/
# - https://extensions.gnome.org/extension/1476/unlock-dialog-background/
# - https://extensions.gnome.org/extension/800/remove-dropdown-arrows/
# - https://extensions.gnome.org/extension/943/workspace-scroll/
# - https://extensions.gnome.org/extension/1116/workspace-switch-wraparound/
# - https://extensions.gnome.org/extension/1473/toggle-mute-on-middle-click/
# - https://extensions.gnome.org/extension/1459/miniview/
# - https://extensions.gnome.org/extension/744/hide-activities-button/
# - https://extensions.gnome.org/extension/352/middle-click-to-close-in-overview/
# OTHER RECOMMENDED:
# - https://extensions.gnome.org/extension/615/appindicator-support/ # this one is baked in now??
# - https://extensions.gnome.org/extension/1166/extension-update-notifier/
# - https://extensions.gnome.org/extension/2224/easy-docker-containers/
# - sudo apt install lm-sensors
# - sudo detect-sensors
# - https://extensions.gnome.org/extension/841/freon/
# TODO:
# - configure dash launchers
# - configure extensions
# load script utils
source script-utils.sh
log 'Installing Go'
exit-if-installed go
wget -O "tmp/go.tar.gz" https://dl.google.com/go/$(curl https://golang.org/VERSION?m=text).linux-amd64.tar.gz
sudo tar -C /usr/local -xzf tmp/go.tar.gz
bashrc golang "
export PATH=\$PATH:/usr/local/go/bin
\nexport GOPATH=\$HOME/projects/go
\nexport PATH=\$PATH:\$GOPATH/bin"
# load script utils
source script-utils.sh
log 'Installing Chrome'
exit-if-installed google-chrome
deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# load script utils
source script-utils.sh
log 'Installing Hyper'
deb https://releases.hyper.is/download/deb
hyper i hyper-material-theme
# load script utils
source script-utils.sh
log 'Installing Lutris'
# exit-if-installed lutris # doesn't work with flatpak :(
# wine
wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
sudo add-apt-repository 'deb http://dl.winehq.org/wine-builds/ubuntu focal main'
sudo apt install --install-recommends winehq-staging -y
# lutris
flatpak remote-add --user flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak update --appstream
flatpak install --user --noninteractive flathub-beta net.lutris.Lutris//beta
# load script utils
source script-utils.sh
log 'Installing MEGAsync'
exit-if-installed megasync
deb https://mega.nz/linux/MEGAsync/xUbuntu_20.04/amd64/megasync-xUbuntu_20.04_amd64.deb
deb https://mega.nz/linux/MEGAsync/xUbuntu_20.04/amd64/nautilus-megasync-xUbuntu_20.04_amd64.deb
# load script utils
source script-utils.sh
log 'Installing Node.js'
exit-if-installed node
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
head -n -3 ~/.bashrc > tmp/.bashrc-node && cat tmp/.bashrc-node > ~/.bashrc
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
bashrc node "
export NVM_DIR=\"\$([ -z \"\${XDG_CONFIG_HOME-}\" ] && printf %s \"\${HOME}/.nvm\" || printf %s \"\${XDG_CONFIG_HOME}/nvm\")\"
\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm
\n[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\" # This loads nvm bash_completion"
nvm i node
# install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install --no-install-recommends yarn -y
# load script utils
source script-utils.sh
log 'Installing Pencil'
deb https://pencil.evolus.vn/dl/V3.1.0.ga/pencil_3.1.0.ga_amd64.deb
# pre-install
# -----------
# add execution permissions to scripts
sudo chmod +x *.sh
# create temporal dir
mkdir tmp
# load script utils
source script-utils.sh
# upgrade everything
log 'Upgrading packages'
sudo apt update
sudo apt upgrade -y --allow-downgrades
sudo apt autoremove -y
sudo snap refresh
# install additional package managers
log 'Installing pip3'
sudo apt install python3-pip -y
# set up ~/.bashrc
log 'Setting up ~/.bashrc'
bashrc pop-os-setup 'export PATH=$PATH:$HOME/.local/bin'
# components
# ----------
./components.sh
# post-install
# ------------
# clean up
log 'Cleaning up...'
sudo apt autoremove -y
sudo rm -rf tmp
# reboot prompt
echo -e "\n\n\n"
read -p "All done! Do you want to reboot now? (recommended) y/n " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
read -p ''
sudo reboot
fi
# TODO:
# - control for vscode existence
# - skip configuration option
# - pop os gnome extensions
# load script utils
source script-utils.sh
log 'Setting up python3 and pip3 as default versions'
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10
log 'Installing virtualenv'
sudo apt install python3.8-venv
log 'Installing PyCharm'
sudo snap install pycharm-community --classic
log 'Installing Poetry'
wget -O tmp/get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
python3 tmp/get-poetry.py -y
bashrc poetry 'export PATH="$HOME/.poetry/bin:$PATH"'
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
# load script utils
source script-utils.sh
log 'Installing Rust'
exit-if-installed rustc
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
bashrc rust 'export PATH="$HOME/.cargo/bin:$PATH"'
# vscode extensions
code --install-extension bungcip.better-toml
code --install-extension rust-lang.rust
code --install-extension serayuzgur.crates
bashrc () {
# Idempotently add text to ~/.bashrc
# $1: section id
# $2: text to add
START_LINE_TEXT="# Pop! OS setup script: $1 start"
END_LINE_TEXT="# $1 end"
START_LINE=$(grep -Fn "$START_LINE_TEXT" ~/.bashrc | cut -f 1 -d ':')
END_LINE=$(grep -Fn "$END_LINE_TEXT" ~/.bashrc | cut -f 1 -d ':')
if [[ -z $START_LINE ]]
then
echo "No .bashrc insertions detected"
else
sed -i.bak -e "$START_LINE,${END_LINE}d" ~/.bashrc
fi
echo "$START_LINE_TEXT" >> ~/.bashrc
echo -e $2 >> ~/.bashrc
echo "$END_LINE_TEXT" >> ~/.bashrc
}
log () {
# log section name with good formatting
# $1: string to log
echo -e "\n\n> $1\n"
}
deb () {
# download and install a deb file
# $1: deb file URL
name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
wget -O "tmp/$name.deb" $1
sudo dpkg -i "tmp/$name.deb"
sudo apt install -fy
}
exit-if-installed () {
# exits the current script if the command exists
# $1: command to test
if [ -x "$(command -v $1)" ]; then
echo "'$1' already exists, skipping..."
exit 1
fi
}
# load script utils
source script-utils.sh
log 'Configuring SSH'
printf "The default SSH key will be generated without a passphrase (if it\ndoesn\'t exist yet), for authentication in services like Github or Gitlab\n"
read -p 'What label do you want to use in the key? ' KEY_LABEL
yes '' | ssh-keygen -t ed25519 -b 4096 -C $KEY_LABEL
printf '\nThis is your public key ~/.ssh/id_ed25519.pub:\n\n'
cat "$HOME/.ssh/id_ed25519.pub"
printf '\n\nCopy the key and save it in the services you want to authenticate with.\nCommon git services:\n\n'
echo '- Gitlab: https://gitlab.com/profile/keys'
echo '- Github: https://github.com/settings/ssh/new'
# load script utils
source script-utils.sh
log 'Installing Steam'
exit-if-installed steam
flatpak install --noninteractive flathub com.valvesoftware.Steam
# load script utils
source script-utils.sh
log 'Installing Telegram'
exit-if-installed telegram-desktop
flatpak install --noninteractive flathub org.telegram.desktop
# load script utils
source script-utils.sh
# fuck
log 'Installing fuck - github.com/nvbn/thefuck'
pip3 install thefuck
bashrc fuck 'eval "$(thefuck --alias)"'
# vim
log 'Installing vim'
sudo apt install vim -y
bashrc vim "
export VISUAL=vim
\nexport EDITOR=\"\$VISUAL\""
# meld
log 'Installing meld'
flatpak install --noninteractive flathub org.gnome.meld
# aliases
log 'Adding aliases'
bashrc aliases "alias pull-all='find . -type d -name .git -exec sh -c cd \"{}\"/../ && pwd && git pull ;'"
# load script utils
source script-utils.sh
log 'Installing Transmission (torrent)'
exit-if-installed transmission-gtk
flatpak install --noninteractive flathub com.transmissionbt.Transmission
# load script utils
source script-utils.sh
log 'Installing VLC'
exit-if-installed vlc
flatpak install --noninteractive flathub org.videolan.VLC
# load script utils
source script-utils.sh
log 'Installing Visual Studio Code and basic extensions'
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get install apt-transport-https -y
sudo apt-get update
sudo apt-get install code -y
code --install-extension ArtisanByteCrafter.poptheme
code --install-extension eamodio.gitlens
# load script utils
source script-utils.sh
log 'Installing WebTorrent Desktop'
exit-if-installed webtorrent-desktop
flatpak install --noninteractive flathub io.webtorrent.WebTorrent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment