PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

Make history prediction location aware

Open SteveL-MSFT opened this issue 3 years ago • 4 comments

Prerequisites

  • [X] Write a descriptive title.

Description of the new feature/enhancement

Include the current location (working directory) as part of history so that predictions based on history would show commands used from that location previously. If nothing is found, then fallback to current strategy.

Example:

> cd ~/repos/powershell
~/repos/powershell> git re

# prediciton would be something like: git reset --hard upstream/master

> cd ~/repos/somethingelse
~/repos/somethingelse> git re

# prediction would be something like: git reset --hard upstream/main
# in this example, you use `main` instead of `master` branch

Proposed technical implementation details (optional)

No response

SteveL-MSFT avatar Nov 06 '22 01:11 SteveL-MSFT

The location awareness for history should not be applied globally, but should only be applied to the selected commands.

For commands like git, it usually has strong association with the folder where it runs in, so history about it should be location aware.

However, there are many other commands that have less or none association with the location where it runs in, such as azure commands, postman, dumpbin, and a lot more. For those command, history entries about them should always be presented to users, regardless of which folder they were executed in previously.

So, it's probably safer not enable folder awareness in history prediction by default, but allow user's configuration on this -- a user can say I want history prediction to apply location awareness to git command only.

Supporting this will require moving to database for storing history entries. A lot of thoughts need to be put into the user experience.

daxian-dbw avatar Feb 06 '23 18:02 daxian-dbw

@SteveL-MSFT @daxian-dbw Regarding my Q in discussions: #3634 is it all covered in this item and in #3380 ? 10x.

iksi4prs avatar Mar 24 '23 13:03 iksi4prs

@iksi4prs I believe the feature in this issue would resolve those two issues

SteveL-MSFT avatar Mar 27 '23 17:03 SteveL-MSFT

@SteveL-MSFT , Thank you for your answer. @daxian-dbw referred me to some example implementation of CommandPredictor. I think what I want to achieve, can be done via my own custom CommandPredictor, but I see that PSSubsystemPluginModel (which from what I understand is required for CommandPredictor) is experimental. (https://learn.microsoft.com/en-us/powershell/scripting/learn/experimental-features?view=powershell-7.3) Do you have any timeline/due date, to decide if this moves from status of "experimental" to removed/mainstream ? I don't want to put some effort, and see it is removed in 7.5 (like PSNativePSPathResolution was removed in 7.3) Or maybe I can vote for it with some examples ?

iksi4prs avatar Mar 29 '23 09:03 iksi4prs