lsd
                                
                                 lsd copied to clipboard
                                
                                    lsd copied to clipboard
                            
                            
                            
                        Cannot `lsd ~` on windows
- os: Windows 10
- lsd --version:- lsd 1.0.0
- echo $TERM: PowerShell 7
- echo $LS_COLORS: -
Expected behavior
The same as ls $env:HOME
Actual behavior
lsd: ~: The system cannot find the file specified. (os error 2).
Notes
It appears that lsd supports globs itself on windows, I would expect it to do the same for other common shell shorthands like ~ that powershell doesn't expand itself.
sound reasonable!
/kind feature /good-first-issue /help
@zwpaper: This request has been marked as suitable for new contributors.
Please ensure the request meets the requirements listed here.
If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.
In response to this:
sound reasonable!
/kind feature /good-first-issue /help
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Although I agree lsd ~ should work in powershell, I think it is a shell feature and should be tackled in the powershell repo
It looks like there are two funny behaviours in pwsh (7.3.7, on windows):
- Tilde is not expanded for native programs (only some cmdlets, e.g. Get-ChildItem ~)
- Pressing <tab>will expand tilde, if there is a completion
Notably, tilde expansion works correctly on mac with pwsh 7.3.7 (case 1 here).
Related:
- https://github.com/PowerShell/PowerShell/issues/20031
- https://github.com/PowerShell/PowerShell/issues/5350
- https://github.com/PowerShell/PowerShell/pull/12386 (This was a PR that introduced tilde expansion in the PSNativePSPathResolutionfeature, but it apparently had some edge cases and was later removed)
Other programs that don't do tilde expansion for pwsh:
- cargo build --manifest-path ~\git\lsd\Cargo.toml
- dotnet build ~/example/example.sln
- eza ~
Tilde is not expanded for native programs (only some cmdlets, e.g.
Get-ChildItem ~)
AFAIK tilde is not expanded for anything, Get-ChildItem receives a path with a tilde in it and internally expands it, the same as any other application that supports tilde paths on windows. (Which is why both gci ~ and gci '~' work the same, there's no shell expansion for the quotes to suppress).
then we may need more information to decide whether this should be implemented
Maybe a vote?
Which is why both gci ~ and gci '~' work the same, there's no shell expansion for the quotes to suppress
Oh yeah you're right, the cmdlets replace the tilde regardless of quotes, so it isn't really an expansion 👍
Other cmdlets like Get-Content also have this "tilde replacement" behaviour.
I opened a PR with powershell: https://github.com/PowerShell/PowerShell/pull/20402
We could consider using the same logic as starship here, which uses dirs-next: https://github.com/starship/starship/blob/7e82cb494c540c7a88cf126ec80aeb0f7ce611bc/src/context.rs#L212C1-L218C6
Do you know any programs that implement tilde replacement? It seems uncommon, a few more examples that don't have it:
- fd . ~/
- bat ~/file
I'm preparing a PR for this support. Worth noting that this expansion is supported when looking for theme files