As a web developer, I usually work on a Mac at work, and on my Windows 10 PC at home.
- From WSL edit your ~/.bashrc file
- Add the following alias:
alias fork='/mnt/c/Windows/System32/cmd.exe /c "%USERPROFILE%\\AppData\Local\Fork\Fork.exe "$(wslpath -w -a .)'
- Save your changes.
- Restart the terminal, so the new alias become available.
- From WSL, navigate to a project folder that use git.
- Run the alias:
- On Windows, the Fork app will open an the project git will be selected for view.
I use vscode and the integrated terminal to manage my projects (for example to run Gulp.js tasks).
Now, and this is important, I made symbolic link between my Window installation
Work folder at
C:\Work\ and my WSL installation at
This make super easy to work with any of my project, regardless if I'm working from Windows or from WSL.
One tool I like a lot is the free git client Fork.
Fork is available for Mac and Windows, but not for Linux. :(
Or that is what I thought, at first. :)
And since I already created a symbolic link for my
Work folder under WSL, all what was left was just to find a way to launch Fork on Windows from the WSL terminal, and to pass the current working WSL folder path converted to a Windows path.
The first part was easy enough. You can launch any Windows app fro WSL using this command:
/mnt/c/Windows/System32/cmd.exe /c [PATH TO THE WINDOWS .EXE FILE]
So to launch Fork I can use this command:
/mnt/c/Windows/System32/cmd.exe /c "%USERPROFILE%\AppData\Local\Fork\Fork.exe.
The Windows variable
%USERPROFILE%will be automatically replaced with your Windows User folder path (ex.:
You can pass a path to Fork executable file to launch the app and to automatically open the git repository on that path.
On linux, the current folder path is represented by
.. But passing this to the Fork executable on Windows means nothing. I needed a way to convert this to a full and absolute Windows path.
And that is what wslpath does!.
So the final command looks like this:
/mnt/c/Windows/System32/cmd.exe /c "%USERPROFILE%\AppData\Local\Fork\Fork.exe "$(wslpath -w -a .)
I added two parameters.
-wparameter translate from a WSL path to a Windows path.
-aparameter force result to absolute path format.
The final step is to add this working command as a
fork alias on my WSL installation, on your [WLS] user
From your WSL installation, edit the
~/.bashrc file and add the following line:
alias fork='/mnt/c/Windows/System32/cmd.exe /c "%USERPROFILE%\AppData\Local\Fork\Fork.exe "$(wslpath -w -a .)'