Also, for a method of @JoL's answer that works on most shells (at least Bash, Fish, Zsh, and even Dash), you can simply create a new user named w
with a home directory pointing to your Windows' user profile. Then ~w/
becomes the shortcut. It also appears to be possible to use ~
for the username, resulting in a ~~
shortcut. See below for details.
There's really no downside to creating a user for this purpose on WSL, since there's no concept of user-level security (i.e. wsl -u root
already gives you full access to everything in a WSL instance without a password).
A simple ...
sudo useradd --home-dir /mnt/c/Users/<username> w
... will work for WSL. However, "best practice" would probably be something more like:
sudo useradd --no-user-group --non-unique -u 1000 -g 1000 --shell /sbin/nologin -f0 -e0 --home-dir /mnt/c/Users/<username> w
This would create a user w
with the same user id and group id (1000:1000) as the primary WSL user (just a personal preference on my part to avoid polluting the system with unnecessary uids/gids). That user would have the nologin shell, an expired password, and a locked account. Again, not that this extra "security" is really needed on WSL anyway.
As with JoL's answer, this will allow:
cp ~/myfile ~w/Documents/
And with the caveat that this could cause problems in some corner cases, you can use useradd
's --badname
option to force it to accept ~
as a username:
sudo useradd --badname --home-dir /mnt/c/Users/<username> "~" # or ...
sudo useradd --badname --no-user-group --non-unique -u 1000 -g 1000 --shell /sbin/nologin -f0 -e0 --home-dir /mnt/c/Users/<username> "~"
Resulting in your original request for:
cp ~/myfile ~~/Documents
~~
, there's a related question that shows up here with even more suggestions on how to do this!