PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.71k stars 295 forks source link

config options aroung saving history items particularly when debugging #4198

Open kilasuit opened 4 days ago

kilasuit commented 4 days ago

Originally raised in the PowerShell/PowerShell repo in issue 24354 by @specerboatepic

Context / Rational

When stepping through a function, one usually "spams" a combination of 'v' 'n' 'c' in debug mode. Once the function ends, or the user enters 'q', debug mode ends but those collection of debug commands are saved in the history of inputted commands, making it harder to find relevant commands in the history (pressing up on the keyboard) while searching through it. These debug commands should be disposed of from the history when debug mode ends because they are no longer useful in the scope of the session.

Thoughts/Findings

This needs work in both PSReadLine and PowerShell's History.cs file hence these issues being linked together This also opens up the potential for new control mechanisms in PSReadLine for how we handle things like sensitive entries going forward as per #4197 and as such is linked to my issue #1886

Proposed implementation in PSReadLine

1) Provide config options to control saving history items when in debug mode - Save-Show/Save-DontShow/DontSave 2) When config set to NotSave - do not add items into the current psreadline file implementation or any future db implementation 3) When config set to Save-Show - add items into the current psreadline file implementation & show in the history lookup 4) When config set to Save-NotShow - add items into the current psreadline file implementation but mark as DontShow or any future db implementation

Similarly we'd need almost same implementation in PowerShell from my understanding