Skip to content

Instantly share code, notes, and snippets.

@schuberty
Last active March 16, 2022 22:55
Show Gist options
  • Save schuberty/da6db7f6d560f95a6c4592982f64f58c to your computer and use it in GitHub Desktop.
Save schuberty/da6db7f6d560f95a6c4592982f64f58c to your computer and use it in GitHub Desktop.
Installing and Setting Up: WSL 2 with Debian, Flutter, VSCode and Oh-My-Posh

Guide to WSL2 with Debian, FLutter, VSCode and Oh-My-Posh!

Need to have:

  1. WSL 2 installed and updated;
  2. VSCode on Windows.

Setting-up Debian with WSL 🤓

It's easy-peasy, 🍋 squeezy! Just use:

$ wsl --install -d Debian

Useful commands for WSL

$ wsl -l -v                                               # List distros, status and version
$ wsl -l -o                                               # List distros available to install
$ wsl --export <distro_name> <file.zip>                   # Export distro
$ wsl --import <distro_name> <install_folder> <file.zip>  # Import distro
$ wsl --unregister <distro_name>                          # Uninstall distro

Tips

Sometimes when exporting/importing distros, to me, occurred the case that not the right user was being loaded. To solve that, create the file /etc/wsl.conf and add the bellow to the file, which USER is your default user to login with:

[user]
default = USER

[network]
hostname = HOSTNAME

Also, if you want to find the Debian file to export or whatever, it's located at:

%appdata%\Local\Packages\TheDebianProject.DebianGNULinux_xxx\LocalState\ext4.vhdx

Installing Flutter at Debian 🤯

Flutter and Android SDK requires some dependences to be installed, which can be downloaded and installed with:

$ sudo apt-get install neofetch vim zip unzip wget curl file xz-utils git libglu1.mesa default-jdk
$ mkdir ~/box/Binaries && cd ~/box/Binaries
$ git clone https://github.com/flutter/flutter.git -b stable
$ echo -e export PATH=\"\$PATH:\$HOME/box/Binaries/flutter/bin\" >> $HOME/.bashrc

In this guide, I store my Flutter binaries at a folder called box, which is where I store everything and after I link to my home. You can store it anywhere as long as you remember the path to it.

After that, download, install and add the sdkmanager to your PATH, as shown bellow.

$ wget https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip
$ unzip commandlinetools-linux-8092744_latest.zip -d $HOME/box/Binaries/android
$ cd $HOME/box/Binaries/android/cmdline-tools
$ mkdir latest | mv $(ls --ignore=latest) latest/
$ echo -e export PATH=\"\$PATH:\$HOME/box/Binaries/android/cmdline-tools/latest/bin\" >> $HOME/.bashrc
$ source $HOME/.bashrc

And now the sdkmanager should be available. Now, install and add to the PATH the necessary packages with it or list the plarforms to check what is available and what you need:

$ sdkmanager --list | grep platform
$ sdkmanager --list | grep build
$ sdkmanager --install "platforms;android-32" "build-tools;32.0.0"
$ sdkmanager --list_installed
$ echo -e export PATH=\"\$PATH:\$HOME/box/Binaries/android/platform-tools\" >> $HOME/.bashrc
$ source $HOME/.bashrc

Last thing, update flutter, accept licenses and run flutter to check for any issue:

$ flutter config --android-sdk $HOME/box/Binaries/android/
$ flutter doctor --android-licenses
$ flutter doctor

If Flutter, Android toolchain and HTTP Host Availability are OK, them it's all done. All this setup is to use a device as the preview, if you want an emulator, them download Android Studio interface.

Useful commands for Flutter Development

$ adb devices                                             # List available devices
$ adb tcpip <port>                                        # Set port for connected devices (usually 5555)
$ adb connect <ip>:<port>                                 # Connect to a device
$ adb kill-server                                         # Kill the server if it is running
$ flutter pub get                                         # Install packages defined at pubspec.yaml

Setting-up the Editor 🥳

...

Installing Oh-My-Posh 😎

Inside Debian, download and enable the execution of oh-my-posh with:

$ sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
$ sudo chmod +x /usr/local/bin/oh-my-posh

After that, download the themes available:

$ mkdir ~/.posh_themes
$ wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.posh_themes/themes.zip
$ unzip ~/.posh_themes/themes.zip -d ~/.posh_themes
$ chmod u+rw ~/.posh_themes/*.json
$ rm ~/.posh_themes/themes.zip

Where ~/.posh_themes is the folder that the themes of oh-my-posh will be installed in.

After that add the following to the end of the file ~/.bashrc, where THEME is the name of the theme you want.

eval "$(oh-my-posh --init --shell bash --config ~/.posh_themes/THEME.omp.json)"

Restart or use the source command.

ENJOY 🤗

The Sources of Knolowdge

Useful Videos for Customization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment