Last active
January 4, 2023 20:18
-
-
Save andria-dev/d6424a58dbd948c4285397db5901f90a to your computer and use it in GitHub Desktop.
WSL Config
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 | |
# function definitions | |
pressAnyKeyToContinue() { | |
read -n 1 -s -r -p "Press any key to continue." | |
} | |
# Get sudo privileges beforehand | |
sudo -v | |
# Welcome the user" | |
echo "Hi $(whoami)! Let's get your Windows Subsystem for Linux (WSL) set up." | |
echo "Let's do a quick check for updates." | |
sudo apt-get update && sudo apt-get upgrade | |
echo "" | |
echo "Now let's start by installing some applications and packages for you." | |
echo "" | |
if [[ ! $(which zsh) ]]; then | |
echo "Installing zsh" | |
sudo apt-get -y install zsh | |
echo "Changing $(whoami)'s and root's shell to $(which zsh)" | |
chsh -s $(which zsh) | |
sudo chsh -s $(which zsh) root | |
echo "Changing their prompt's as well" | |
prompt_file=\ | |
'''# Inserts a blank line between shell promptsadd_newline = true | |
# Replace the "❯" symbol in the prompt with "➜" | |
[character] | |
success_symbol = "[➜](bold green)" | |
error_symbol = "[➜](bold red)" | |
# Disable the package module, hiding it from the prompt completely | |
[package] | |
disabled = true | |
''' | |
echo "$prompt_file" > $HOME/.config/starship.toml | |
sudo echo "$prompt_file" > /root/.config/starship.toml | |
else | |
echo "ZSH is already installed: $(which zsh)" | |
fi | |
# Install homebrew so that we can install other things. | |
if [[ ! $(which brew) ]]; then | |
echo "Installing homebrew (https://brew.sh)" | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | |
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> $HOME/.zshrc | |
else | |
echo "Homebrew is already installed: $(which brew)" | |
fi | |
# Install our commands | |
echo """ | |
Installing the following applications via homebrew | |
git (https://git-scm.com) | |
hub (https://github.com/github/hub) | |
rg (https://github.com/BurntSushi/ripgrep) | |
watchman (https://facebook.github.io/watchman) | |
tree (https://formulae.brew.sh/formula/tree) | |
bat (https://github.com/sharkdp/bat) | |
exa (https://github.com/ogham/exa) | |
java | |
starship (https://starship.rs/) | |
z (https://github.com/rupa/z) | |
""" | |
brew install git hub ripgrep watchman tree bat exa java starship z | |
echo 'eval "$(starship init zsh)"' >> $HOME/.zshrc | |
echo '. /home/linuxbrew/.linuxbrew/etc/profile.d/z.sh' >> $HOME/.zshrc | |
echo ''' | |
# Aliases | |
alias ls="exa" | |
alias ll="exa -l" | |
alias la="exa -a" | |
alias cd="z" | |
''' >> $HOME/.zshrc | |
echo "Installing rust, cargo, rustup, etc. (https://crates.io/)" | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | |
echo """ | |
# Add Cargo Binaries | |
PATH=\"\$HOME/.cargo/bin:\$PATH\" | |
""" | tee -a $HOME/.bashrc $HOME/.zshrc 1>/dev/null | |
echo "Configuring git!" | |
git config --global credential.helper store | |
git config --global user.email "[email protected]" | |
git config --global user.name "Andria Brown" | |
git config --global core.editor "code --wait" | |
if [[ ! $(which volta) ]]; then | |
echo "Installing volta (https://docs.volta.sh/)" | |
sudo mkdir /opt/volta | |
sudo chown $(whoami):$(whoami) /opt/volta | |
export VOLTA_HOME=/opt/volta | |
curl https://get.volta.sh | bash -s -- --skip-setup | |
export PATH="$VOLTA_HOME/bin:$PATH" | |
echo 'export VOLTA_HOME="/opt/volta"' | sudo tee -a /etc/zsh/zshenv 1>/dev/null | |
echo 'export PATH="$VOLTA_HOME/bin:$PATH"' | sudo tee -a /etc/zsh/zshenv 1>/dev/null | |
else | |
echo "Volta is already installed." | |
fi | |
volta install node@latest | |
volta install yarn@latest | |
# Install pip3 so we can install AdvancedNewFile | |
echo "Installing pip3 (python package manager)" | |
sudo apt-get -y install python3-pip | |
echo "Installing ad (https://github.com/tanrax/terminal-AdvancedNewFile)" | |
pip3 install --user advance-touch | |
echo "Installing git open (https://github.com/paulirish/git-open)" | |
npm install -g git-open | |
echo """# set PATH so it includes user's private bin if it exists | |
if [[ -d \"\$HOME/.local/bin\" ]]; then | |
PATH=\"\$HOME/.local/bin:\$PATH\" | |
fi | |
""" >> $HOME/.zshrc | |
# Set up SSH keychain if no SSH exists | |
if [[ ! -d "$HOME/.ssh" ]]; then | |
echo "Configuring your SSH keychain now." | |
read -p "What is your email? " email | |
ssh-keygen -t ed25519 -C $email -f $HOME/.ssh/id_ed25519 | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_ed25519 | |
echo "If you would like to add your SSH key to GitHub please do so now." | |
cat $HOME/.ssh/id_ed25519.pub | clip.exe | |
echo "The public key is in your clipboard." | |
echo "https://github.com/settings/keys" | |
pressAnyKeyToContinue | |
fi | |
if [[ ! -f "$HOME/.vimrc" ]]; then | |
echo "Creating vim configuration." | |
echo """ | |
set tabstop=2 | |
set shiftwidth=2 | |
set autoindent | |
set smartindent | |
set mouse=a | |
set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:» | |
set number | |
if has('syntax') | |
syntax enable | |
silent! colorscheme eldar | |
endif | |
""" > $HOME/.vimrc | |
mkdir $HOME/.vim | |
mkdir $HOME/.vim/colors | |
curl 'https://raw.githubusercontent.com/agude/vim-eldar/master/colors/eldar.vim' -o $HOME/.vim/colors/vim-eldar | |
fi | |
if [[ ! -d "$HOME/Workspace" ]]; then | |
echo "Creating your Workspace directory." | |
mkdir $HOME/Workspace | |
fi | |
echo "Cloning some GitHub repositories down if they aren't already there." | |
cd $HOME/Workspace | |
if [[ ! -d "./use-shopping-cart" ]]; then | |
echo "use-shopping-cart" | |
git clone https://github.com/dayhaysoos/use-shopping-cart.git | |
cd use-shopping-cart | |
yarn | |
cd .. | |
fi | |
if [[ ! -d "./brownie" ]]; then | |
echo "brownie" | |
git clone https://github.com/andria-dev/brownie.git | |
cd brownie | |
yarn | |
cd .. | |
fi | |
if [[ ! -d "./portfolio" ]]; then | |
echo "portfolio" | |
git clone https://github.com/andria-dev/portfolio.git | |
cd portfolio | |
yarn | |
cd .. | |
fi | |
if [[ ! -d "./react-spring-modal" ]]; then | |
echo "react-spring-modal" | |
git clone https://github.com/andria-dev/react-spring-modal.git | |
cd react-spring-modal | |
yarn | |
cd .. | |
fi | |
cd $HOME | |
echo "Done setting up your WSL! Have fun 😊" | |
zsh |
Author
andria-dev
commented
Mar 18, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment