iTranslated by AI
WSL Development Environment: Managing Environments with dotfiles
tl;dr
Using dotfiles allows you to easily set up your development environment with the following steps:
- Fork the
dotfilesrepository - Clone
dotfilesinto your WSL environment - Create symbolic links to manage configuration files
- Edit the
profilescript for automatic loading
This enables efficient management and version control of environment configurations.
Enjoy!
Introduction
This article introduces how to centrally manage configuration files on WSL using dotfiles.
This makes it easy to perform backups, migrate environments, and synchronize settings.
Technical Terms
Here is a list of technical terms used in this article:
-
WSL (Windows Subsystem for Linux):
A feature for running Linux on Windows -
dotfiles:
A repository for managing configuration files for UNIX/Linux-based OS -
XDG Base Directory:
A directory standard specification for organizing configuration files, caches, etc., to make management easier -
Repository:
A place in a version control system where the change history of files and directories is saved -
Symbolic Link:
A shortcut for referring to a file or directory from another location
1. What is dotfiles?
dotfiles is a repository for efficiently managing configuration files.
It makes backing up, migrating, and sharing settings easy.
2. Initial Setup of dotfiles
2.1 Forking the dotfiles repository
Fork the dotfiles repository to your own GitHub account to copy the dotfiles repository.
This allows you to personalize your WSL environment using your own dotfiles and build your very own development environment.
Access the dotfiles repository and click the [Fork] button.

Note:
Forking creates a dotfiles repository in your own GitHub account.
2.2 Cloning the dotfiles repository
Clone the forked dotfiles repository to Debian on WSL to download the dotfiles onto WSL.
Run the following command:
git clone https://github.com/<myaccount>/dotfiles
Note:
Replace <myaccount> with your GitHub account when running the command.
The execution result will look like this:
Cloning into 'dotfiles'...
remote: Enumerating objects: 1580, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 1580 (delta 19), reused 39 (delta 13), pack-reused 1523
Receiving objects: 100% (1580/1580), 295.93 KiB | 14.09 MiB/s, done.
Resolving deltas: 100% (730/730), done.
As a result, the dotfiles on GitHub are copied to your local PC.
2.3 Creating Symbolic Links
By creating symbolic links, you can manage your configuration files efficiently and keep them constantly up to date.
This makes it easy to reflect changes back into the repository.
Run the following script to create symbolic links:
~/.local/dotfiles/scripts/bootstrap-linux/dotfileslinks.sh
When executed, the following links are created:
.config -> ./.local/dotfiles/linux/.config
.editorconfig -> ./.config/.editorconfig
bin -> /home/<myaccount>/.local/dotfiles/linux/opt/bin
etc -> /home/<myaccount>/.local/dotfiles/linux/opt/etc
Note:
<myaccount> will be your own account.
2.4 Rewriting /etc/profile and ~/.profile
In this step, we ensure that the dotfiles settings are automatically loaded every time the shell starts.
This maintains the consistency and reproducibility of the environment configuration.
Run the following script:
~/.local/dotfiles/scripts/bootstrap-linux/addscripts.sh
When executed, the following content is added to the files:
if [[ -f /opt/etc/profile]]; then
. /opt/etc/profile
fi
## exec dotfiles
if [[ -f "$HOME/.config/profile" ]]; then
. $HOME/.config/profile
fi
Conclusion
In this article, we explained how to manage the WSL environment using the dotfiles repository.
By utilizing dotfiles, you can not only quickly and efficiently build a WSL development environment but also continuously manage that environment.
Let's set up your development environment quickly and enjoy a new programming experience.
Happy Hacking!
References
Websites
-
What is Windows Subsystem for Linux?
URL: https://learn.microsoft.com/en-us/windows/wsl/about
Description: Detailed explanation of WSL and its usage from official Microsoft documentation. -
dotfiles-Arch Wiki
URL: https://wiki.archlinux.org/title/Dotfiles
Description: Version control methods fordotfilesand their benefits. -
XDG Base Directory-Arch Wiki
URL: https://wiki.archlinux.org/title/XDG_Base_Directory
Description: Basic principles ofXDG Base Directoryand a list of applications that comply with it.
Discussion