Created
July 10, 2026 21:00
-
-
Save matthewpersico/69c61a197d8488fb1d0c8e1d6d8fc899 to your computer and use it in GitHub Desktop.
Creating a link to Windows home under WSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -L looks for the argument as a soft link | |
| if [ ! -L "\$HOME/winhome" ]; then | |
| # shellcheck disable=SC2016 - $env inside single quotes generates a warning. shellcheck | |
| # does not have enough context to understand we want to pass the $ to | |
| # the command. | |
| # The powershell command prints the value of the environment variable USERPROFILE from Windows, | |
| # which is the home dir. In my case 'C:\Users\matth'. | |
| $ The wslpath converts Windows paths to WSL paths. In this case: | |
| 'C:\Users\matth' => '/mnt/c/users/matth' | |
| ln -s "\$(wslpath "\$(powershell.exe -NoProfile -Command '\$env:USERPROFILE')")" "\$HOME/winhome" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment