Skip to content

Instantly share code, notes, and snippets.

@kernkraft235
Last active November 1, 2024 05:41
Show Gist options
  • Select an option

  • Save kernkraft235/01158fd6dc27e59610f7b1d246167704 to your computer and use it in GitHub Desktop.

Select an option

Save kernkraft235/01158fd6dc27e59610f7b1d246167704 to your computer and use it in GitHub Desktop.

Acessing your Windows Files from within WSL

You can access you Windows folders at /mnt/c/Users/$WIN_USER I have set the environment variable to always equal your actual Windows username

For convenience I made symbolic links in your Linux home directory to your Windows home dir and your Downloads folder Use the command 'ls' to see whats in your home directory

Python

I have initialized a virtualenv that automatically starts when you load your shell This is useful so that you can install pip packages psuedo-globally without interferring with the system Python install The virtualenv folder is located ~/.venv You can see it by using ls -a while in your home directory

Docker

Docker is installed and I've started a local portainer instance already This provides a nice GUI for managing docker containers Access it at https://localhost:9443 Depending on WSL2's default config options this URL might not be accessible from Windows, we can fix it tho

#!/usr/bin/env bash
cd
if [ -d "$HOME/Downloads" ]; then
rm -rf "$HOME/Downloads"
fi
echo "export WINUSER=$WINUSER" >> .bashrc
ln -s /mnt/c/Users/"$WIN_USER" "$HOME"/
ln -s /mnt/c/Users/"$WIN_USER" "$HOME"/Downloads
sudo apt update && sudo apt upgrade -y
sudo apt install -y \
libosmesa6 libglx-mesa0 mesa-drm-shim pciutils \
mesa-va-drivers intel-media-va-driver-non-free \
build-essential git git-extras cmake flex bison meson direnv \
p7zip bzip2 zstd bat cht.sh dialog minicom \
python3-virtualenv python3-pip python3-pip-whl python3-setuptools-whl \
python3-requests python3-samba python3-tk pipx pandoc \
python3-pygments python3-pil python3-plotly imagemagick \
bash-completion shellcheck fish fzf eza micro btop tealdeer \
ripgrep plocate jq yq csvkit csvkit-doc csvtool \
xorg xterm xserver-xorg-video-intel xserver-xorg-input-libinput \
xsel xclip xcb xcb-proto xdg-utils ssh-askpass xdg-desktop-portal \
wayland-protocols waypipe weston wl-clipboard xwayland xwayland-run \
r-base r-cran-plotly r-cran-rsconnect \
shiny-server r-cran-shinythemes r-cran-shinyjs \
curl wget httpie arp-scan arping nmap ssh samba smbclient \
docker.io docker-compose-v2 docker-doc docker-buildx \
sqlite3 sqlite3-tools \
openjdk-21-jdk openjdk-21-jre
python3 -m virtualenv .venv
source .venv/bin/activate
echo "source ~/.venv/bin/activate" >> .bashrc
echo "export COLORTERM=truecolor" >> .bashrc
echo "export MICRO_TRUECOLOR=1" >> .bashrc
echo ".venv" >> .gitignore
echo ".motd_shown" >> .gitignore
echo ".bash_logout" >> .gitignore
echo ".landscape" >> .gitignore
echo ".sudo_as_admin_successful" >> .gitignore
echo "alias ls=eza" >> .bashrc
alias ls=eza
echo "Your Windows Download folder is now linked to your Ubuntu Download folder"
echo "You can find it at ~/Downloads"
echo "Your Windows Home folder is now linked to ~/$WIN_USER"
ls
echo ""
echo "Your shell will start inside a python virtual environment automatically, so you are safe to install common pip packages"
sudo docker volume create portainer_data
sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.21.4
echo "Your personal portainer instance is running at https://localhost:9443 "
echo "ctrl+click to open if you are using Windows Terminal and not the old Windows console"
exec bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment