You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tab completion replaces tilde with full path #20033
This seems to be a damned if they do and damned if they don't thing. There is another recent issue complaining that external windows exes don't understand ~ in a path. Tab expanding ~ helps to ensure a working path gets sent to things but it annoyed me until I grew used to it. There's probably a wider issue about making ~ work everywhere so that it can happily stay unexpanded by tab
As noted, with ~on Windows, when calling external programs, the behavior happens to be somewhat of a blessing currently, as ~ isn't automatically expanded on invocation.
In general, however, I agree that the behavior is unhelpful:
It is visually somewhat jarring.
It interferes with the ability to retain a path in its abstract form, which is important if you want to copy the path to, say, sample code in a tutorial.
It can significantly lengthen your command (see below).
Note that the problem is more general, in that it also affects (environment) variable-based paths; e.g., on Windows:
# Pressing TAB at the end of this line expands to a literal, user-specific path; e.g.# 'C:\Users\jdoe\AppData\Roaming\Microsoft\'Get-ChildItem$env:APPDATA\Mi
For the external programs issue, I would expect PowerShell should expand ~ from a PSPath (Temp: / ~) to a provider path (C:\temp) when calling external programs since they don't know what a PSPath is or may not have a concept of ~.
This issue is specifically just for tab completion and command history so that what the user typed in is preserved. In my use case it creates a long command with the full path when I'm looking back and just need the relative path from ~.
What prompted me originally to log this was when my custom PSDrive GitHub got changed to the provider path but found it was TabExpansionPlusPlus custom TabExpansion2 function that was messing with PSDrives and with no profile worked as expected but ~ still was changed.
MartinGC94 you're right, I must have accidently ran pwsh stable when the test with no profile. I can't reproduce on 7.4-preview 4. I can still reproduce the example using environment variables though. Did you fix that as well in your PR?
MartinGC94, that's great news, but I can confirm Thomas Nieto (@ThomasNieto)'s finding that environment variables are still converted to literal paths.
Looking at your PR, I see that the issue at hand has a duplicate dating back to 2017:
Great, I was afraid there was some weird edge case I had missed. As for the variable replacement, I have some WIP code locally to fix that, I've just been too lazy to finish it. Expect to see a PR for that in the near future.
Reacted by Thomas Nieto, Michael Klement and Dominic Slee
Activity
jhoneill commentedon Jul 27, 2023
This seems to be a damned if they do and damned if they don't thing. There is another recent issue complaining that external windows exes don't understand ~ in a path. Tab expanding ~ helps to ensure a working path gets sent to things but it annoyed me until I grew used to it. There's probably a wider issue about making ~ work everywhere so that it can happily stay unexpanded by tab
mklement0 commentedon Jul 27, 2023
As noted, with
~on Windows, when calling external programs, the behavior happens to be somewhat of a blessing currently, as~isn't automatically expanded on invocation.In general, however, I agree that the behavior is unhelpful:
Note that the problem is more general, in that it also affects (environment) variable-based paths; e.g., on Windows:
ThomasNieto commentedon Jul 27, 2023
For the external programs issue, I would expect PowerShell should expand ~ from a PSPath (Temp: / ~) to a provider path (C:\temp) when calling external programs since they don't know what a PSPath is or may not have a concept of
~.This issue is specifically just for tab completion and command history so that what the user typed in is preserved. In my use case it creates a long command with the full path when I'm looking back and just need the relative path from
~.What prompted me originally to log this was when my custom PSDrive
GitHubgot changed to the provider path but found it wasTabExpansionPlusPluscustomTabExpansion2function that was messing with PSDrives and with no profile worked as expected but~still was changed.MartinGC94 commentedon Jul 27, 2023
Strange, you say this is happening in preview 4 but this was actually fixed in the preview 4 release by this PR: #19489

It works as expected on my PC:
Have you tried loading PS without a custom profile?
ThomasNieto commentedon Jul 27, 2023
MartinGC94 you're right, I must have accidently ran pwsh stable when the test with no profile. I can't reproduce on 7.4-preview 4. I can still reproduce the example using environment variables though. Did you fix that as well in your PR?
mklement0 commentedon Jul 27, 2023
MartinGC94, that's great news, but I can confirm Thomas Nieto (@ThomasNieto)'s finding that environment variables are still converted to literal paths.
Looking at your PR, I see that the issue at hand has a duplicate dating back to 2017:
Once the environment-variable issue is also handled, both this and the aforementioned issue should be closed.
MartinGC94 commentedon Jul 27, 2023
Great, I was afraid there was some weird edge case I had missed. As for the variable replacement, I have some WIP code locally to fix that, I've just been too lazy to finish it. Expect to see a PR for that in the near future.
ThomasNieto commentedon Jul 28, 2023
Closing as a duplicate of #5350.