Note:
~ expansion for native utilities currently fundamentally only works on _Unix_ platforms - but Windows would benefit from it too: see #10675
Fully emulating the logic of ~ expansion in PowerShell requires recognizing _partial_ quoting of sub-tokens in arguments (e.g., ~/'foo bar'), which may turn out to be challenge based on how argument parsing currently works.
On a Unix-like platform:
# Quoting the argument as a whole always suppresses ~ expansion.
/bin/echo '~/foo' | Should -Be '~/foo'
# Both commands should expand ~ to the value of $HOME,
# because the ~/ prefix is unquoted.
/bin/echo ~/foo | Should -Not -BeLike '~/*'
/bin/echo ~/'foo bar' | Should -Not -BeLike '~/*'
All tests should succeed.
The 3rd test fails, because the partially quoted argument prevented ~ expansion - even though ~/ is _unquoted_.
Expected like wildcard '~*' to not match '~/foo bar', but it did match.
Note that in POSIX-like shells - whose behavior here is being emulated - /bin/echo ~/'foo bar' indeed expands ~, as expected.
PowerShell Core 7.0.0-rc.1
It's also missing support ~username syntax; for example, if I have a user foo with a home directory of /home/foo, even if I'm currently running as user bar, ~foo/test should expand to /home/foo/test. I don't think it's too important to prioritize that feature, since it's not widely known, but I figured I'd mention it.
No, I believe the ~user expansion is widely known, at least among linux developers and power users and is VERY useful.
E.g., I'm setting up an account for a friend on my windows server, I may want to do something like:
cpi -rec vimfiles, src, .vimrc, .gitconfig ~other_user
It should tab complete the expansion too.
~username expansion should be a separate issue
:tada:This issue was addressed in #12386, which has now been successfully released as v7.1.0-preview.3.:tada:
Handy links:
Most helpful comment
It's also missing support ~username syntax; for example, if I have a user
foowith a home directory of/home/foo, even if I'm currently running as userbar,~foo/testshould expand to/home/foo/test. I don't think it's too important to prioritize that feature, since it's not widely known, but I figured I'd mention it.