Created
January 7, 2022 14:02
-
-
Save gtm19/21d689f12d1dee0c277f0feea1d4302f to your computer and use it in GitHub Desktop.
WSL Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Utils | |
e_header() { | |
printf "\n$(tput setaf 3)%s$(tput sgr0)\n" "$@" | |
sleep 2 | |
} | |
e_success() { | |
printf "\n$(tput setaf 2)✓ %s$(tput sgr0)\n" "$@" | |
sleep 2 | |
} | |
e_line() { | |
echo "----------------------------------------" | |
} | |
# git | |
e_header "Installing git" | |
e_line | |
sudo apt update | |
sudo apt install -y git | |
e_success "git successfully installed" | |
e_line | |
# .zsh and Oh My Zsh | |
# Install Zsh and friends: | |
e_header "Installing zsh and Oh My Zsh" | |
e_line | |
sudo apt update | |
sudo apt install -y zsh curl vim imagemagick jq unzip | |
# Install oh-my-zsh | |
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
# Install some external plugins: | |
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions | |
git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting | |
# Set Zsh as default shell: | |
chsh -s /bin/zsh | |
e_success "zsh and Oh My Zsh successfully installed" | |
e_line | |
# GitHub CLI | |
e_header "Installing GitHub CLI" | |
e_line | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
sudo apt update | |
sudo apt install -y gh | |
e_success "GitHub CLI successfully installed" | |
e_line | |
# Python and PIP3 | |
e_header "Installing Python 3 and pip" | |
e_line | |
sudo apt update | |
sudo apt install -y python3 python3-pip | |
e_success "Python 3 and pip successfully installed" | |
e_line | |
# R | |
e_header "Installing R" | |
e_line | |
# update indices | |
sudo apt update -qq | |
# install two helper packages we need | |
sudo apt install --no-install-recommends -y software-properties-common dirmngr | |
# add the signing key (by Michael Rutter) for these repos | |
# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc | |
# Fingerprint: 298A3A825C0D65DFD57CBB651716619E084DAB9 | |
sudo wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc | |
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed | |
sudo add-apt-repository -y "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" | |
sudo apt install --no-install-recommends -y r-base | |
# and repo: | |
sudo add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+ | |
sudo apt install --no-install-recommends -y r-cran-rstan | |
e_success "R successfully installed" | |
e_line | |
# libraries for SF | |
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable | |
sudo apt update | |
sudo apt install -y libudunits2-dev libgdal-dev libgeos-dev libproj-dev | |
# Radian | |
e_header "Installing Radian" | |
e_line | |
pip3 install -U radian | |
e_success "Radian successfully installed" | |
e_line | |
# rstudio-server | |
e_header "Installing RStudio Server" | |
e_line | |
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) | |
sudo apt update | |
sudo apt install gdebi-core | |
wget https://download2.rstudio.org/server/bionic/amd64/rstudio-server-2021.09.1-372-amd64.deb -P $tmp_dir | |
sudo gdebi --n $tmp_dir/rstudio-server-2021.09.1-372-amd64.deb | |
rm -rf $tmp_dir | |
e_success "RStudio Server successfully installed" | |
e_line | |
# node, NPM, and Yarn | |
e_header "Installing Node and NPM" | |
e_line | |
sudo apt update | |
sudo apt install -y nodejs npm | |
e_success "Node and NPM successfully installed" | |
e_line | |
e_header "Installing yarn" | |
e_line | |
sudo npm install --global yarn | |
e_success "yarn successfully installed" | |
e_line | |
# VS Code Extensions | |
e_header "Installing VS Code extensions" | |
e_line | |
code --install-extension ms-vscode.sublime-keybindings | |
code --install-extension emmanuelbeziat.vscode-great-icons | |
code --install-extension MS-vsliveshare.vsliveshare | |
code --install-extension rebornix.ruby | |
code --install-extension dbaeumer.vscode-eslint | |
code --install-extension Rubymaniac.vscode-paste-and-indent | |
code --install-extension ikuyadeu.r | |
e_success "VS code extenstions installed!" | |
e_line | |
# dotfiles | |
e_header "Setting up dotfiles" | |
e_line | |
mkdir -p ~/code | |
git clone https://github.com/gtm19/dotfiles.git ~/code/dotfiles | |
CURRENT_DIR=$(pwd) | |
cd ~/code/dotfiles/ | |
chmod u+x install.sh | |
./install.sh | |
cd $CURRENT_DIR | |
e_success "dotfiles successfully setup" | |
e_line | |
# rbenv | |
e_header "Installing rbenv" | |
e_line | |
command -v rvm &> /dev/null || \ | |
rvm implode && \ | |
sudo rm -rf ~/.rvm && \ | |
rm -rf ~/.rbenv | |
sudo apt update | |
sudo apt install -y \ | |
build-essential \ | |
tklib \ | |
zlib1g-dev \ | |
libssl-dev \ | |
libffi-dev \ | |
libxml2 \ | |
libxml2-dev \ | |
libxslt1-dev \ | |
libreadline-dev | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
e_success "rbenv installation complete. Restart shell and run 'rbenv install 3.1.0' to get Ruby" | |
e_line | |
# postgres | |
e_header "Installing Postgresql" | |
e_line | |
sudo apt update | |
sudo apt install -y postgresql postgresql-contrib libpq-dev build-essential | |
sudo /etc/init.d/postgresql start && \ | |
sudo -u postgres psql --command "CREATE ROLE `whoami` LOGIN createdb;" | |
sudoers_file=/etc/sudoers.d/postgresql | |
sudo echo "`whoami` ALL=NOPASSWD:/etc/init.d/postgresql start" | sudo tee $sudoers_file | |
sudo chmod 440 $sudoers_file | |
e_success "Postgresql installation complete." | |
e_line | |
# login to GH CLI | |
gh auth login -s 'user:email' -w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment