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

PSReadLine history search with wildcards #3681

Open
fullenw1 opened this issue May 10, 2023 · 6 comments
Open

PSReadLine history search with wildcards #3681

fullenw1 opened this issue May 10, 2023 · 6 comments
Labels
Area-HistoryImprovements Label for tracking different improvements to history Issue-Enhancement It's a feature request.

Comments

@fullenw1
Copy link

fullenw1 commented May 10, 2023

Summary of the new feature / enhancement

Often I remember some elements of former command lines.
However when I used the forward/backward search capability,
I have usually to go trough a lot of suggestions before finding the match.
Being able to use wild cards would dramatically improve the research experience.

Exemple of current behavior:

I need to search for a line with:

Get-ADUser -Property Description, Manager -Identity accountX

Currently I have to go through:

Get-ADUser -Identity accountA
Get-ADUser -Property Description -Identity accountC
Get-ADUser -Property Manager -Identity accountD
Get-ADUser -Property Description, Manager -Identity accountN
Get-ADUser -Property Description, Manager -Identity accountO
Get-ADUser -Property Description, Manager -Identity accountX

Request:

I wish I could make my search with:

Get-ADUser*accountX

Proposed technical implementation details (optional)

A similar feature already exists, though currently limited to the file system.

https://github.com/Ink230/DirectoryPredictor

@fullenw1 fullenw1 added the Issue-Enhancement It's a feature request. label May 10, 2023
@jhoneill
Copy link

The difficulty with this is I want to search for commands where I have done things with *.tmp or whatever, so how does one differentiate between searching for a wildcard, and searching with a wildcard.

If you have predictive history on you can toggle between "Suggest closest" and "Show me options" with F2. So for that example if I know the command is in the history but isn't the most recent I'll start with get-adu and then press F2 and pick the right one. Not perfect, especially if muscle memory is hard coded to # whatever or [ctrl]+[r] whatever, but another tool if it suits.

@fullenw1 fullenw1 changed the title PSReadLine history seach with wildcards PSReadLine history search with wildcards May 10, 2023
@fullenw1
Copy link
Author

fullenw1 commented May 10, 2023

The difficulty with this is I want to search for commands where I have done things with *.tmp or whatever, so how does one differentiate between searching for a wildcard, and searching with a wildcard.

If you have predictive history on you can toggle between "Suggest closest" and "Show me options" with F2. So for that example if I know the command is in the history but isn't the most recent I'll start with get-adu and then press F2 and pick the right one. Not perfect, especially if muscle memory is hard coded to # whatever or [ctrl]+[r] whatever, but another tool if it suits.

Yes, being able to use wildcards with predictive history would be great too! 😃

There is already somebody developing something similar but currently only limited to the filesystem.
https://github.com/Ink230/DirectoryPredictor
Maybe you should have a look...

GitHub
PowerShell Module which displays related files, actively from the current directory, in your PSReadLine autocompletion list. - GitHub - Ink230/DirectoryPredictor: PowerShell Module which displays r...

@kilasuit
Copy link

I think this issue should be moved across to the PSReadline repo - @SteveL-MSFT / @daxian-dbw can you do this for me?

@kilasuit
Copy link

Also this perhaps would be something that could be better achieved whenever this issue gets implemented

@daxian-dbw daxian-dbw transferred this issue from PowerShell/PowerShell May 15, 2023
@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 15, 2023
@daxian-dbw
Copy link
Member

@fullenw1 Just so I'm clear, are you asking for wildcard matching in history prediction, or the history searching, like when using Ctrl+r?

@fullenw1
Copy link
Author

fullenw1 commented May 22, 2023

@fullenw1 Just so I'm clear, are you asking for wildcard matching in history prediction, or the history searching, like when using Ctrl+r?

@daxian-dbw , originally it was for the history searching, like when using CTRL + R.

However, one can assume that if wildcards can be used with the history prediction too,
then the history searching would become nearly useless,
except for those who don't want/like to use the history prediction.

Currently, I still use both.
But I noticed that with the improvement of the history prediction (thanks to the CompletionPredictor module), I use less the history searching.

@StevenBucher98 StevenBucher98 added Area-HistoryImprovements Label for tracking different improvements to history and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-HistoryImprovements Label for tracking different improvements to history Issue-Enhancement It's a feature request.
Projects
None yet
Development

No branches or pull requests

5 participants