[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot lsd ~ on windows #903

Open
Nemo157 opened this issue Sep 15, 2023 · 7 comments · May be fixed by #975
Open

Cannot lsd ~ on windows #903

Nemo157 opened this issue Sep 15, 2023 · 7 comments · May be fixed by #975
Labels
kind/feature New feature request need-more-info open-for-vote Add a thumbs up if you think this would be a good addition os/windows

Comments

@Nemo157
Copy link
Nemo157 commented Sep 15, 2023
  • 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.

@zwpaper
Copy link
Member
zwpaper commented Sep 16, 2023

sound reasonable!

/kind feature
/good-first-issue
/help

@muniu-bot
Copy link
muniu-bot bot commented Sep 16, 2023

@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.

@muniu-bot muniu-bot bot added kind/feature New feature request good first issue Good for newcomers help wanted Extra attention is needed labels Sep 16, 2023
@domsleee
Copy link
Contributor

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):

  1. Tilde is not expanded for native programs (only some cmdlets, e.g. Get-ChildItem ~)
  2. 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:

Other programs that don't do tilde expansion for pwsh:

  • cargo build --manifest-path ~\git\lsd\Cargo.toml
  • dotnet build ~/example/example.sln
  • eza ~

@Nemo157
Copy link
Author
Nemo157 commented Sep 29, 2023

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).

@zwpaper
Copy link
Member
zwpaper commented Oct 1, 2023

then we may need more information to decide whether this should be implemented

Maybe a vote?

@zwpaper zwpaper added need-more-info open-for-vote Add a thumbs up if you think this would be a good addition and removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 1, 2023
@domsleee
Copy link
Contributor
domsleee commented Oct 2, 2023

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: PowerShell/PowerShell#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

@ofersadan85
Copy link
Contributor
ofersadan85 commented Jan 2, 2024

I'm preparing a PR for this support. Worth noting that this expansion is supported when looking for theme files

@ofersadan85 ofersadan85 linked a pull request Jan 2, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature request need-more-info open-for-vote Add a thumbs up if you think this would be a good addition os/windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants