Skip to content

Commit

Permalink
Update to support installation inside wsl
Browse files Browse the repository at this point in the history
  • Loading branch information
codyduong committed Nov 1, 2023
1 parent 97c566b commit 22380a2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
65 changes: 65 additions & 0 deletions linux/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
#!/usr/bin/env bash

MAJOR_VERSION=$(uname -r | awk -F '.' '{print $1}')
MINOR_VERSION=$(uname -r | awk -F '.' '{print $2}')

is_wsl() {
# Check for the presence of the WSLInterop file.
if [[ -f /proc/sys/fs/binfmt_misc/WSLInterop ]]; then
return 0
fi

# Check for the presence of the WSL_DISTRO_NAME environment variable.
if [[ -n "$WSL_DISTRO_NAME" ]]; then
return 0
fi

# Check if the kernel name contains the string "Microsoft".
if [[ $(uname -r) =~ Microsoft ]]; then
return 0
fi

return 1
}

_curl() {
which curl >/dev/null &&
echo "\033[1;33mcurl found, skipping...\033[0m" ||
Expand All @@ -19,6 +41,8 @@ _git() {
}

_i3() {
is_wsl && return 0;

which i3 >/dev/null &&
echo "\033[1;33mi3 found, skipping...\033[0m" ||
(
Expand Down Expand Up @@ -144,6 +168,8 @@ _gpg() {
}

_code() {
is_wsl && return 0;

which code >/dev/null &&
echo "\033[1;33mcode found, skipping\033...[0m" ||
(
Expand Down Expand Up @@ -177,6 +203,8 @@ _ripgrep() {
}

_pavucontrol() {
is_wsl && return 0;

which pavucontrol >/dev/null &&
echo "\033[1;33mpavucontrol found, skipping...\033[0m" ||
(
Expand All @@ -186,6 +214,8 @@ _pavucontrol() {
}

_brightnessctl() {
is_wsl && return 0;

which brightnessctl >/dev/null &&
echo "\033[1;33mbrightnessctl found, skipping...\033[0m" ||
(
Expand All @@ -195,6 +225,8 @@ _brightnessctl() {
}

_theme() {
is_wsl && return 0;

echo "\033[1;34mAdding solarized themes to \\usr\\share\\themes\\033[0m"
mkdir ~/tmp/solarized-themes
git clone -n Solarized-Dark-gtk-theme-colorpack https://github.com/rtlewis88/rtl88-Themes.git ~/tmp/solarized-themes --depth 1
Expand All @@ -204,6 +236,37 @@ _theme() {
rm ~/tmp/solarized-themes -r
}

_bun() {
which unzip >/dev/null && (
echo "\033[1;34minstalling unzip...\033[0m"
sudo apt install unzip -y
) || echo "\033[1;33unzip found, skipping...\033[0m"

! which curl >dev/null && (
echo "\033[1;31mcurl not found! Required for bun installation...\033[0m"
return 0;
)

# Minimum for bun is 5.1
if [ $MAJOR_VERSION -ge 5 ] && [ $MINOR_VERSION -ge 1 ]; then
which bun >/dev/null &&
echo "\033[1;33mbun found, skipping...\033[0m" ||
(
echo "\033[1;34minstalling bun...\033[0m"
curl -fsSL https://bun.sh/install | bash
)
fi
}

_gcloud() {
which gcloud >/dev/null &&
echo "\033[1;33minstalling gcloud...\033[0m" ||
(
echo "\033[1;34minstalling gcloud...\033[0m"
curl https://sdk.cloud.google.com | bash
)
}

_dotfiles() {
echo "\033[1;34mMoving dotfiles (home) to ~\033[0m"
sudo cp ~/dotfiles/linux/home/. -r ~/
Expand Down Expand Up @@ -233,5 +296,7 @@ _ripgrep
_pavucontrol
_brightnessctl
_theme
_bun
_gcloud
_dotfiles
_otherfiles
3 changes: 2 additions & 1 deletion linux/home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ HIST_STAMPS="yyyy-mm-dd"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
source $ZSH/oh-my-zsh.sh
# source $ZSH/oh-my-zsh.sh

# User configuration

Expand Down Expand Up @@ -121,6 +121,7 @@ eval $(thefuck --alias)
alias cls="clear"
alias lock="i3lock-fancy"
alias ripgrep="rg"
alias reload="exec zsh"

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
Expand Down

0 comments on commit 22380a2

Please sign in to comment.