Last active
November 16, 2021 20:35
-
-
Save gquittet/3dfabbca58483b78cb56a10504efdbec to your computer and use it in GitHub Desktop.
Script to setup WSL
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
#!/usr/bin/env bash | |
# Ensure script is running with bash | |
if [ -z "$BASH_VERSION" ]; then | |
echo "You need to run this script with bash!" | |
exit 1 | |
fi | |
############################################################################### | |
# PREPARATION | |
############################################################################### | |
install() { | |
# shellcheck disable=SC2068 | |
sudo apt-get install -y $@ | |
} | |
update_system() { | |
sudo apt-get update | |
} | |
upgrade_system() { | |
sudo apt-get upgrade -y | |
} | |
clean() { | |
sudo apt-get autoremove -y | |
sudo apt-get autoclean -y | |
} | |
install_langs() { | |
install language-pack-fr language-pack-fr-base manpages | |
} | |
install_base_utilities() { | |
local BASE_UTILITIES="curl software-properties-common stow zip unzip" | |
install "$BASE_UTILITIES" | |
} | |
install_ppa_s() { | |
local PPA_S="ppa:fish-shell/release-3 ppa:aos1/diff-so-fancy ppa:neovim-ppa/unstable" | |
for PPA in $PPA_S; do sudo apt-add-repository -y "$PPA"; done | |
update_system | |
} | |
setup_ssh() { | |
mkdir -p "$HOME"/.ssh | |
} | |
prepare_wsl() { | |
export USERNAME="$USER" | |
export DOTFILES_FOLDER="$HOME/.dotfiles" | |
export XDG_DATA_HOME="$HOME/.local/share" | |
update_system && upgrade_system | |
install_base_utilities | |
install_langs | |
install_ppa_s | |
setup_ssh | |
} | |
############################################################################### | |
# SETUP | |
############################################################################### | |
setup_dotfiles() { | |
if [ ! -d "$DOTFILES_FOLDER" ]; then | |
git clone https://github.com/gquittet/dotfiles.git "$DOTFILES_FOLDER" | |
cd "$DOTFILES_FOLDER" || exit | |
stow {bat,fish,git,nvim,scripts,starship,wsl-x11} | |
xrdb -merge "$HOME"/.Xresources | |
cd - || exit | |
fi | |
} | |
setup_shell() { | |
local FISH_FZF_PACKAGES="fish fzf bat fd-find" | |
install "$FISH_FZF_PACKAGES" | |
sudo usermod --shell "$(which fish)" "$USERNAME" >/dev/null | |
sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --yes | |
ln -s "$(which fdfind)" ~/.local/bin/fd | |
ln -s "$(which batcat)" ~/.local/bin/bat | |
# FX (JSON manipulation) | |
local FX_PATH="$HOME"/.local/bin/fx | |
curl -L https://github.com/antonmedv/fx/releases/latest/download/fx-linux.zip | gunzip -c - > "$FX_PATH" | |
chmod +x "$FX_PATH" | |
} | |
install_utilities() { | |
local UTILITIES="diff-so-fancy" | |
install $UTILITIES | |
} | |
install_editor() { | |
local UTILITIES="neovim python3-pynvim" | |
install $UTILITIES | |
} | |
############################################################################### | |
# DEV | |
############################################################################### | |
install_node() { | |
local NODEJS_PACKAGES="nodejs npm" | |
export NVM_DIR="$XDG_DATA_HOME/nvm" | |
mkdir -p "$NVM_DIR" | |
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - | |
sudo apt install -y nodejs | |
install "$NODEJS_PACKAGES" | |
# NVM | |
mkdir -p "$NVM_DIR" | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash | |
} | |
install_python() { | |
local PYTHON_PACKAGES="python-dev python3-dev python3-pip python3-venv python3-wheel" | |
install "$PYTHON_PACKAGES" | |
# Pipenv | |
pip install --user pipenv | |
} | |
setup_dev_env() { | |
local DEV_FOLDER="$HOME/dev" | |
install_node | |
install_python | |
mkdir -p "$DEV_FOLDER" | |
} | |
############################################################################### | |
# GUI | |
############################################################################### | |
setup_icons() { | |
curl -s -L https://api.github.com/repos/B00merang-Artwork/Windows-10/releases/latest | fx .zipball_url | xargs -I %%% wget -O Windows-10-icons.zip %%% && \ | |
unzip -d Windows-10-icons Windows-10-icons.zip && \ | |
rm Windows-10-icons.zip && \ | |
mv Windows-10-icons/* Windows-10-icons-1 && \ | |
rm -rf Windows-10-icons && \ | |
mv Windows-10-icons-1/ Windows-10-icons && \ | |
sudo mv Windows-10-icons /usr/share/icons | |
# Cursor | |
git clone https://github.com/yeyushengfan258/We10XOS-cursors We10XOS-cursors && \ | |
cd We10XOS-cursors && \ | |
sudo ./install.sh && \ | |
cd - && \ | |
rm -rf We10XOS-cursors | |
install pop-icon-theme | |
sudo update-icon-caches /usr/share/icons/* | |
} | |
setup_themes() { | |
# Light | |
curl -s -L https://api.github.com/repos/B00merang-Project/Windows-10/releases/latest | fx .zipball_url | xargs -I %%% wget -O Windows-10-light.zip %%% && \ | |
unzip -d Windows-10-light Windows-10-light.zip && \ | |
rm Windows-10-light.zip && \ | |
mv Windows-10-light/* Windows-10-light-1 && \ | |
rm -rf Windows-10-light && \ | |
mv Windows-10-light-1/ Windows-10-light && \ | |
sudo mv Windows-10-light /usr/share/themes | |
# Dark | |
curl -s -L https://api.github.com/repos/B00merang-Project/Windows-10-Dark/releases/latest | fx .zipball_url | xargs -I %%% wget -O Windows-10-dark.zip %%% && \ | |
unzip -d Windows-10-dark Windows-10-dark.zip && \ | |
rm Windows-10-dark.zip && \ | |
mv Windows-10-dark/* Windows-10-dark-1 && \ | |
rm -rf Windows-10-dark && \ | |
mv Windows-10-dark-1/ Windows-10-dark && \ | |
sudo mv Windows-10-dark /usr/share/themes | |
install pop-gtk-theme | |
} | |
setup_fonts() { | |
# FantasqueSansMono | |
curl -L -o FantasqueSansMono.zip https://github.com/ryanoasis/nerd-fonts/releases/latest/download/FantasqueSansMono.zip && \ | |
unzip -d FantasqueSansMono FantasqueSansMono.zip && \ | |
rm FantasqueSansMono.zip && \ | |
sudo mv FantasqueSansMono /usr/share/fonts && \ | |
fc-cache -fv | |
# Ubuntu Mono and Windows fonts | |
install ubuntu-mono ttf-mscorefonts-installer | |
# Segoe UI Font | |
wget https://raw.githubusercontent.com/mrbvrz/segoe-ui-linux/master/install.sh && \ | |
chmod +x install.sh && \ | |
./install.sh && \ | |
rm install.sh | |
# Emoji | |
install fonts-recommended fonts-noto-color-emoji | |
} | |
install_gui_utilities() { | |
install lxappearance gnome-tweaks caja pluma | |
} | |
setup_gui() { | |
setup_icons | |
setup_themes | |
setup_fonts | |
install_gui_utilities | |
} | |
############################################################################### | |
# FIX | |
############################################################################### | |
fix_git_issue_with_tls() { | |
sudo update-alternatives --set fakeroot /usr/bin/fakeroot-tcp | |
} | |
apply_fixes() { | |
fix_git_issue_with_tls | |
} | |
############################################################################### | |
# MAIN | |
############################################################################### | |
log() { | |
printf "%s\n" "$@" | |
} | |
main() { | |
log "Preparing WSL..." | |
prepare_wsl >/dev/null | |
log "Apply fixes..." | |
apply_fixes >/dev/null | |
log "Installing dotfiles..." | |
setup_dotfiles >/dev/null | |
log "Setup shell..." | |
setup_shell >/dev/null | |
log "Installing utilities..." | |
install_utilities >/dev/null | |
log "Installing editor..." | |
install_editor >/dev/null | |
log "Setup dev environment..." | |
setup_dev_env >/dev/null | |
log "Setup GUI..." | |
setup_gui >/dev/null | |
log "Cleaning..." | |
clean >/dev/null | |
log "Done! Enjoy your new dev environment 🎉" | |
sleep 1 | |
log "Close and open again your WSL 🔔" | |
sleep 5 | |
clear | |
exit | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment