Skip to content

Instantly share code, notes, and snippets.

@jdiegosierra
Forked from DaniGuardiola/components.sh
Last active April 8, 2020 15:13
Show Gist options
  • Save jdiegosierra/2421a196f802ed406bbdbe8f188f5a41 to your computer and use it in GitHub Desktop.
Save jdiegosierra/2421a196f802ed406bbdbe8f188f5a41 to your computer and use it in GitHub Desktop.
Pop! OS: personal after-install setup script | execution: $ source <(wget -qO - gist.githubusercontent.com/jdiegosierra/2421a196f802ed406bbdbe8f188f5a41/raw/7f0f1d5c2c869f146dc4470b2d84f810892f7682/downloader.sh)
# load script utils
source script-utils.sh
log 'Installing Balena Etcher Appimage'
exit-if-installed balena-etcher-electron
echo "deb https://deb.etcher.io stable etcher" | sudo tee /etc/apt/sources.list.d/balena-etcher.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61
sudo apt-get update
sudo apt-get install balena-etcher-electron -y
# 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
./python.sh
./rust.sh
./node.sh
./go.sh
./docker.sh
./postman.sh
./virtualbox.sh
./zsh.sh
# UX and graphic design software
./pencil.sh
# appearance
./cool-prompt.sh
./gnome.sh
# other software
./google-chrome.sh
./discord.sh
./skype.sh
./telegram.sh
./vlc.sh
./webtorrent.sh
./steam.sh
./transmission.sh
./mega.sh
./spotify.sh
./balenaetcher.sh
./gparted.sh
./shutter.sh
./lutris.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
sudo snap install 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.25.1/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, but the last time
# I tested it I was on 19.10. 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 - gist.githubusercontent.com/jdiegosierra/2421a196f802ed406bbdbe8f188f5a41/raw/7f0f1d5c2c869f146dc4470b2d84f810892f7682/downloader.sh)
# Method 2 (advanced)
# 1. Download this gist as ZIP and extract it
# URL: https://gist.github.com/jdiegosierra/2421a196f802ed406bbdbe8f188f5a41/
# 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 J. Diego Sierra (forked from Dani Guardiola)"
echo -e "-----------------------------------------------------\n"
echo -e "Source code: https://gist.github.com/jdiegosierra/2421a196f802ed406bbdbe8f188f5a41/"
echo -e "Instructions: https://gist.githubusercontent.com/jdiegosierra/2421a196f802ed406bbdbe8f188f5a41/raw/7f0f1d5c2c869f146dc4470b2d84f810892f7682/downloader.sh/\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/2421a196f802ed406bbdbe8f188f5a41/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
touch ~/.gitignore_global
cat > ~/.gitignore_global << EOF
# Intellij
.idea
*.iml
*.iws
.idea-compl
*.sc
EOF
git config --global core.excludesfile ~/.gitignore_global
git config --global user.email $GIT_EMAIL
git config --global user.name $GIT_NAME
git config --global push.default simple
echo 'export GIT_EDITOR=nano' >> ~/.bashrc
echo 'export PATH=$PATH:~/.dotfiles/git/bin/' >> ~/.bashrc
# Git Aliases
sudo sh -c "echo 'git diff -p -R --no-color | grep -E \\\"^(diff|old|new) mode)\\\" --color=never | git apply' >> ~/.dotfiles/git/bin/git-reset-permissions && chmod +x ~/.dotfiles/git/bin/git-reset-permissions"
sudo sh -c "echo 'git status' >> ~/.dotfiles/git/bin/git-st && chmod +x ~/.dotfiles/git/bin/git-st"
sudo sh -c "echo 'git log --graph --abbrev-commit --oneline' >> ~/.dotfiles/git/bin/git-tree && chmod +x ~/.dotfiles/git/bin/git-tree"
sudo sh -c "echo 'git add -u && git commit -m \"WIP\"' >> ~/.dotfiles/git/bin/git-wip && chmod +x ~/.dotfiles/git/bin/git-wip"
sudo sh -c "echo 'git pull --rebase --autostash' >> ~/.dotfiles/git/bin/git-pull-clean && chmod +x ~/.dotfiles/git/bin/git-pull-clean"
sudo sh -c "echo 'git reset HEAD~1 --mixed' >> ~/.dotfiles/git/bin/git-undo && chmod +x ~/.dotfiles/git/bin/git-undo"
sudo sh -c "echo 'git add -A && git reset --hard > /dev/null 2>&1' >> ~/.dotfiles/git/bin/git-discard && chmod +x ~/.dotfiles/git/bin/git-discard"
sudo sh -c "echo 'git add --all && git commit --amend --no-edit' >> ~/.dotfiles/git/bin/git-amend && chmod +x ~/.dotfiles/git/bin/git-amend"
# Git extra commands
sudo apt-get install git-extras
# load script utils
source script-utils.sh
log 'Installing Gnome tweaks'
sudo apt install gnome-tweaks -y
log 'Installing Gnome extension manager scripts'
sudo wget -O /usr/local/sbin/gnomeshell-extension-manage https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/ubuntugnome/gnomeshell-extension-manage
sudo chmod +x /usr/local/sbin/gnomeshell-extension-manage
# TODO:
# - https://extensions.gnome.org/extension/906/sound-output-device-chooser/
# - https://extensions.gnome.org/extension/615/appindicator-support/
# - https://extensions.gnome.org/extension/1166/extension-update-notifier/
# - https://extensions.gnome.org/extension/307/dash-to-dock/
# - https://extensions.gnome.org/extension/1112/screenshot-tool/
# - https://extensions.gnome.org/extension/7/removable-drive-menu/
# - https://extensions.gnome.org/extension/352/middle-click-to-close-in-overview/
# - 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/2224/easy-docker-containers/
# - sudo apt install lm-sensors
# - sudo detect-sensors
# - https://extensions.gnome.org/extension/841/freon/
# - sudo apt install gir1.2-clutter-1.0
# - https://extensions.gnome.org/extension/1476/unlock-dialog-background/
# - https://extensions.gnome.org/extension/800/remove-dropdown-arrows/
# - https://extensions.gnome.org/extension/1459/miniview/
# - https://extensions.gnome.org/extension/744/hide-activities-button/
# - 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/go1.13.3.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 Gparted'
exit-if-installed gparted
sudo apt-get install gparted -y
# load script utils
source script-utils.sh
log 'Installing Lutris'
exit-if-installed lutris
sudo add-apt-repository ppa:lutris-team/lutris -y
sudo apt-get install lutris -y
# load script utils
source script-utils.sh
log 'Installing MEGAsync'
exit-if-installed megasync
deb https://mega.nz/linux/MEGAsync/xUbuntu_19.10/amd64/megasync-xUbuntu_19.10_amd64.deb
deb https://mega.nz/linux/MEGAsync/xUbuntu_19.10/amd64/nautilus-megasync-xUbuntu_19.10_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.0/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
npm install -g @angular/cli
# 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 snap'
sudo apt install snapd -y
bashrc snap "PATH=$PATH:/snap/bin"
sudo snap install core
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 'Installing Postman'
exit-if-installed postman
sudo snap install postman
# 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.7-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 settings.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 'Installing Shutter'
exit-if-installed shutter
sudo add-apt-repository ppa:linuxuprising/shutter -y
sudo apt install shutter -y
# load script utils
source script-utils.sh
log 'Installing Skype'
exit-if-installed skype
sudo snap install skype --classic
# load script utils
source script-utils.sh
log 'Installing Spotify'
exit-if-installed spotify
sudo snap install spotify
# 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
sudo apt install steam -y
# load script utils
source script-utils.sh
log 'Installing Telegram'
exit-if-installed telegram-desktop
sudo snap install 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'
sudo apt install meld -y
# 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
sudo apt install transmission -y
# load script utils
source script-utils.sh
log 'Installing VirtualBox'
exit-if-installed virtualbox
sudo apt-get install virtualbox -y
sudo apt-get install virtualbox-ext-pack -y
# load script utils
source script-utils.sh
log 'Installing VLC'
exit-if-installed vlc
sudo snap install vlc
# load script utils
source script-utils.sh
log 'Installing Visual Studio Code and basic extensions'
sudo snap install code --classic
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
deb https://github.com/webtorrent/webtorrent-desktop/releases/download/v0.21.0/webtorrent-desktop_0.21.0_amd64.deb
# load script utils
source script-utils.sh
log 'Installing ZSH'
exit-if-installed zsh
sudo apt-get install zsh -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment