WSL ubuntu m windows terminal and ls_colors
Tags: wsl, ubuntu, windowsterminal, lscolors
Published: 2022-05-08 13:04:47

Brief Intro

If you're reading this you're probably like me and develop on windows, it has served me right but I recently found out that you can't avoid Linux as a developer,
configuring a dual boot solution was the go-to solution for this for a while. 
but that comes with some limitations, for one you can only use one at a time and that was not an option when I was developing a server that was almost complete on windows until I had to add caching and Redis is a Linux only solution. 
My options were to clone the project into a Linux environment or find a way to run limited Linux which would let me run the server in windows and Redis on Linux then I discovered the windows subsystem for linux (WSL) which allows you to run Linux in windows and have access to the Windows file system and a parallel Linux file system , that was perfect for my needs 

The first step is installing wsl
Run the simple command:

`wsl --install
`
windows will do a bunch of stuff under the hood includind downloading a linux distro (latest ubuntu by default)
[see](https://docs.microsoft.com/en-us/windows/wsl/install) for more info and custom install instructions

## Configuring windows terminal with WSL2 and ubuntu

you'll need a terminal to use linux bt sadly window's default offerings are less than desirable, that's why they made windows terminal
[download from windows store](https://www.microsoft.com/store/productId/9N0DX20HK701)

Navigate to your terminal, click on the dropdown button next to the plus sign on the tab area to open the side panel

![windows terminal dropdown button](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/699h5p0lvwcgs3h78gry.png)



if ubuntu peofile doesn't already exist 
go to settings>scroll down on list of profiles , at the bottom 
click on open json file

in the profiles

```
  {
     "commandline": "wsl.exe ~ -d Ubuntu",
     "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
     "hidden": false,
     "name": "Ubuntu",
     "source": "Windows.Terminal.Wsl",
     "startingDirectory": "~"
 },
```
save in your editor and exit

you can optionally add if you have fish shell, for it to load fish by default on startup
`
 "commandline": "wsl.exe ~ -d Ubuntu fish",
`
you might notice the ls colors being a little unreadable in which case you might want to do the following:

open ~/.bashrc with your favorite code editor

i'll use vscode

```
code ~/.bashrc
```
>Note :the first line should be all one line , it won't work if put in multiple lines


```
LS_COLORS='ex=01;91:rs=0:di=1;33:ln=01;35:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=01;35;40:st=37;44:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;35:*.au=00;35:*.flac=00;35:*.mid=00;35:*.midi=00;35:*.mka=00;35:*.mp3=00;35:*.mpc=00;35:*.ogg=00;35:*.ra=00;35:*.wav=00;35:*.axa=00;35:*.oga=00;35:*.spx=00;35:*.xspf=00;35:';

 
export LS_COLORS

```
if you relaunch your terminal the changes will appear
[for more info on this](https://www.howtogeek.com/307899/how-to-change-the-colors-of-directories-and-files-in-the-ls-command/)

Now you have linux running in your windows enviroment with access to the main machine's file system 
happy coding

more references 
[basic wsl commands](https://docs.microsoft.com/en-us/windows/wsl/basic-commands)
[Windows terminal configuration](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-general)

[How to add gcc and Betty linter for c/cpp development](https://dev.to/tigawanna/linux-ccpp-in-wsl-ubuntu-setup-1fdc)