ArchLinux config on WSL2 to developers

Versão em português

In the last few days, I needed to format my equipment again and I felt the need to have documentation to speed up this part of configuring my development environment. I use some apps in my day-to-day life that prevent me from usi…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Diego Chueri

Versão em português

In the last few days, I needed to format my equipment again and I felt the need to have documentation to speed up this part of configuring my development environment. I use some apps in my day-to-day life that prevent me from using only Linux, for a while I used dual-boot, but the need to restart the PC for some quick code changes made me look for another alternative, in this case, WSL.

The initial idea was just to document to facilitate my configuration process, but as lemonade comes from lemon, I decided to share it with you here. I'm not going to sound deep about the WSL or the reasons for each choice, but I'm open to suggestions and dialogues with anyone interested.

If you don't know what WSL is or are looking for more information about it, follow the link to the official Microsoft documentation (numerous articles can be found by a quick search):

What is the Windows Subsystem for Linux?

Installing WSL

If you have not yet installed WSL on your Windows, enter the following command in Windows PowerShell:

wsl --install

Install WSL | Microsoft Learn

Windows Terminal

I prefer to use Windows Terminal for two main reasons: customization and taking advantage of some Linux commands. Installation is simple and can be done using the link below:

Windows Terminal - Microsoft Store Apps

Install Arch

This version of Arch that I use is very lightweight compared to other options (like Manjaro):

https://github.com/yuk7/ArchWSL

Just extract the files to a preferred folder and run the Arch file, which will start the installation.

Creating a user

Once the installation is complete, it's time to configure a user and make it the default at startup, avoiding using the root user. Just follow the commands below, remembering to replace {username} and {password} with the desired name and password:

echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
useradd -m -G wheel -s /bin/bash {username}
passwd {password}

Now to set the created user as default, close Arch and open your terminal in the folder where the Arch.exe file is and enter the following command:

.\Arch.Exe config --default-user {username}

How to Setup | ArchWSL official documentation

Updating distro packages

Before updating we need to initialize pacman's keyring:

sudo pacman-key --init

And also perform the initial configuration of the keys with the:

sudo pacman-key --populate
sudo pacman -Sy archlinux-keyring
sudo pacman -Syu

pacman/Package signing - ArchWiki

Initialize keyring | ArchWSL official documentation (wsldl-pg.github.io)

Package managers

I will initially install the YARN and NPM managers:

sudo pacman -S yarn npm

As AUR manager I use Yay:

sudo pacman -S --needed git base-devel

Finally, with “Rust” package to use “cargo”:

sudo pacman -S rust

To install Yay it will be necessary to clone the repository, as after installation the files will no longer be used I choose to create a temporary folder to facilitate deletion later:

mkdir tmp
cd tmp

Now just clone the repository and build it with makepkg:

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Jguer/yay: Yet another Yogurt - An AUR Helper written in Go (github.com)

Z Shell

Install ZSH:

yay -S zsh

Customizing the Terminal

Changing the terminal theme

Windows Terminal Themes has several themes ready for your terminal, just choose the theme of your choice and click on the “Get theme” button, and with that selected theme will be copied to your clipboard. My favorite theme is Dracula.

Just go back to the terminal, use the shortcut Ctrl + , to open the Configurations, and click on Open JSON file in the lower left corner.

Print screen

After the last theme (themes are inside the "schemes" array), put a , and paste the chosen theme. Save and close the file.

Note: If you "break" the JSON file, while the terminal is open it may work normally, but when restarting it you will find an error similar to this. If this is tolerated, just click “OK”, open the JSON file again, check the syntax and save the file.

Return to the Settings screen, open the Arch profile, under “Additional settings” and click on “Appearance”. Now just change the “Color Scheme” to the desired option. Click “Save” and close the settings.

Customizing ZSH

To change the ZSH theme I use Powerlevel10k:

yay -S --noconfirm zsh-theme-powerlevel10k-git
echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
chsh -s /usr/bin/zsh

Restart the terminal.

Font

After installing Powerlevel10k, when you start the terminal again, a settings screen will appear where some symbols should be displayed:

Print of terminal

If you are unable to view the displayed symbols, just install one of the calls Nerd Fonts and change the Arch profile font in “Additional Settings” > “Appearance” > “Font type”.

When you want to access the Powerlevel10k configuration screen again, just type:

p10k configure

Plugins

In my case, I usually use the following plugins:

  • ZSH Autosuggestions: which does an autocomplete based on my command history;

  • exa: serves as an alternative to “ls”; and

  • bat: alternative “cat”.

mkdir .zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
cargo install bat exa

Open the .zshrc file in your preferred editor and add to the end of the file:

code .zshrc
alias ls="exa --icons"
alias bat="bat --style-auto"

NVM

For managing node versions I use NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

Docker

It is necessary to have Docker Desktop installed on Windows. With that, just type in the terminal:

yay -S docker

And finally, enable the Arch distro in the Resources of Docker Desktop.

And is this

Throughout the article, I tried to provide some useful links so that each one can perform the best configuration as appropriate. As said at the beginning, feel free to make suggestions, as well as indicate any errors that occurred during the process and also share your preferences with others.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Diego Chueri


Print Share Comment Cite Upload Translate Updates
APA

Diego Chueri | Sciencx (2022-11-21T16:27:22+00:00) ArchLinux config on WSL2 to developers. Retrieved from https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/

MLA
" » ArchLinux config on WSL2 to developers." Diego Chueri | Sciencx - Monday November 21, 2022, https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/
HARVARD
Diego Chueri | Sciencx Monday November 21, 2022 » ArchLinux config on WSL2 to developers., viewed ,<https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/>
VANCOUVER
Diego Chueri | Sciencx - » ArchLinux config on WSL2 to developers. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/
CHICAGO
" » ArchLinux config on WSL2 to developers." Diego Chueri | Sciencx - Accessed . https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/
IEEE
" » ArchLinux config on WSL2 to developers." Diego Chueri | Sciencx [Online]. Available: https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/. [Accessed: ]
rf:citation
» ArchLinux config on WSL2 to developers | Diego Chueri | Sciencx | https://www.scien.cx/2022/11/21/archlinux-config-on-wsl2-to-developers/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.