Skip to content

Instantly share code, notes, and snippets.

@zaucy
Last active January 5, 2024 03:26
Show Gist options
  • Select an option

  • Save zaucy/b51cf2090b577b3b6e3e539d7804dd53 to your computer and use it in GitHub Desktop.

Select an option

Save zaucy/b51cf2090b577b3b6e3e539d7804dd53 to your computer and use it in GitHub Desktop.
Personal wsl2 ubuntu setup
#!/bin/bash
set -e
sudo tee /etc/wsl.conf > /dev/null <<EOF
[interop]
appendWindowsPath = false
EOF
sudo apt-add-repository -y ppa:fish-shell/release-3
sudo apt -y update && sudo apt -y upgrade
sudo apt -y install git fish make python3
echo "#####################"
echo "## Configuring git ##"
echo "#####################"
echo -n "git user.name: "
read git_user_name
git config --global user.name "$git_user_name"
echo -n "git user.email: "
read git_user_email
git config --global user.email "$git_user_email"
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
echo "############################################"
echo "## Downloading and installing bazel tools ##"
echo "############################################"
mkdir -p ~/.local/bin
# bazelisk
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.2.1/bazelisk-linux-amd64
mv bazelisk-linux-amd64 ~/.local/bin/bazel
chmod +x ~/.local/bin/bazel
# ibazel
wget https://github.com/bazelbuild/bazel-watcher/releases/download/v0.11.0/ibazel_linux_amd64
mv ibazel_linux_amd64 ~/.local/bin/ibazel
chmod +x ~/.local/bin/ibazel
# buildifier
wget https://github.com/bazelbuild/buildtools/releases/download/0.29.0/buildifier
mv buildifier ~/.local/bin/buildifier
chmod +x ~/.local/bin/buildifier
# buildozer
wget https://github.com/bazelbuild/buildtools/releases/download/0.29.0/buildozer
mv buildozer ~/.local/bin/buildozer
chmod +x ~/.local/bin/buildozer
# unused_deps
wget https://github.com/bazelbuild/buildtools/releases/download/0.29.0/unused_deps
mv unused_deps ~/.local/bin/unused_deps
chmod +x ~/.local/bin/unused_deps
mkdir -p ~/.config/fish
cat << EOF > ~/.config/fish/config.fish
set -Ua fish_user_paths ~/.local/bin
set -Ua fish_user_paths /mnt/c/Users/zekew/AppData/Local/Programs/Microsoft VS Code/bin
EOF
export NVS_HOME="$HOME/.nvs"
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
echo "######################################"
echo "## Setting up fish as default shell ##"
echo "######################################"
chsh --shell /usr/bin/fish
mkdir -p /tmp/bass
git clone https://github.com/edc/bass.git /tmp/bass
cd /tmp/bass
make install
cd ~
rm -rf /tmp/bass
# Patching bass to use python3 so we don't need python 2 installed or python3
# symlinked to 'python'
sed -i 's/python /python3 /g' ~/.config/fish/functions/bass.fish
sed -i 's/python /python3 /g' ~/.config/fish/functions/__bass.py
cat << EOF > ~/.config/fish/functions/nvs.fish
function nvs
bass source ~/.nvs/nvs.sh ';' nvs $argv
end
EOF
echo "##############################"
echo "## Creating larger swapfile ##"
echo "##############################"
sudo dd if=/dev/zero of=/swapfile bs=1M count=16384 oflag=append conv=notrunc
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo "SUCCESS! Logout and log back in to complete your setup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment