PSReadLine icon indicating copy to clipboard operation
PSReadLine copied to clipboard

A more intelligent & useful history file & way to query it

Open kilasuit opened this issue 5 years ago • 11 comments

It would be great to have a much more intelligent & complex history file than the current simple implementation that we currently have, although to achieve this I expect that it would likely be much more computationally expensive than the current implementation.

Ideally I would like to see this be more structured & complex and able to be queried in a way that allows for much better analytics of common command use that enables inspection on the count of use being aliased or using the full command name, common parameter combinations as well as a count of the use of each parameter & arguments to that parameter.

Some loose goals

  • [ ] Local Sqlite file - Default option
  • [ ] Remote sqllite or other db format (for cross machine history reasons) - Configurable option
  • [ ] Configuration options - including continue to use current file for those that want it
  • [ ] Initial base DB Schema
  • [ ] User Extensibility of DB Schema
  • [ ] Additional Querying cmdlets

kilasuit avatar Oct 16 '20 22:10 kilasuit

Cross session sharing makes this somewhat hard to implement without a proper database.

I see sqlite might be a reasonable option.

lzybkr avatar Oct 16 '20 23:10 lzybkr

The suggestion to use Frecency algorithm for history prediction (#1808) and also possibly a local ML model to provide predictions from the history patterns would also require a more powerful storage for history. So yes, we can look into replacing the history file with sqlite.

daxian-dbw avatar Oct 30 '20 18:10 daxian-dbw

@daxian-dbw This still would be a big win for PSReadline going forward and it would be great if you and I could find some time together to make it happen

kilasuit avatar Apr 10 '23 05:04 kilasuit

I have been wanting to do this, but it just couldn't get in the priority cut due to the limited team resources. @StevenBucher98 has put this in the 2.3.0 release consideration, and hopefully we will get commitment for this one.

By the way, the Microsoft.Data.Sqlite package looks a good fit for this work.

daxian-dbw avatar Apr 10 '23 18:04 daxian-dbw

I realise it's not a smallish bit of work to implement especially the more I think about additional configurability options we may want to add. Let me try and carve out some time properly going forward so that I can be of use here (starting with me actually writing some C# after a long long time saying I want to!)

kilasuit avatar Apr 10 '23 21:04 kilasuit

This looks interesting.

I tackled some of the requests in a proof-of-concept module I made a bit back: https://github.com/StartAutomating/PowerHistory

I'd hope that one of these days, we'd be more willing to accept PowerShell contributions to the PowerShell language.

StartAutomating avatar Apr 10 '23 21:04 StartAutomating

... So yes, we can look into replacing the history file with sqlite.

@daxian-dbw Perhaps it would be better if both persistence mechanisms were available and users could decide which one to use according to their preference or need.

claudio-salvio avatar Apr 10 '23 21:04 claudio-salvio

@daxian-dbw Perhaps it would be better if both persistence mechanisms were available and users could decide which one to use according to their preference or need.

Maybe, and this might just be crazy talk here, but maybe one could store persistent history in a vault (rather than reinvent a wheel here)

StartAutomating avatar Apr 10 '23 21:04 StartAutomating

@claudio-salvio This is something that I would look to have as configurable by user with a preference to use the sqlite by default (or other remote db option) but not remove it until a major version if any available module use metrics shows a mass switchover from current implementation.

kilasuit avatar Apr 10 '23 21:04 kilasuit

Maybe, and this might just be crazy talk here, but maybe one could store persistent history in a vault (rather than reinvent a wheel here)

I feel that this would be a goal for the longer term but feel that this is loosely captured under configurability options

kilasuit avatar Apr 10 '23 21:04 kilasuit

I'd always sort of intended on implementing something here, I'd been thinking about it before this issue was opened.

There are now some options that work across shells. I've been using atuin and it's meeting my needs for now.

lzybkr avatar Sep 02 '23 00:09 lzybkr