-
Notifications
You must be signed in to change notification settings - Fork 320
Description
Prerequisites
- Write a descriptive title.
Description of the new feature/enhancement
If I run this command, then PSReadLine does not save it to the history file by default, because of the sensitive name Password:
(Import-Clixml "${Env:HOME}\credential.clixml").GetNetworkCredential().Password | Set-ClipboardHowever, the command itself does not contain any passwords. I would like PSReadLine to save this command to the history file so that I can more easily run similar commands in future PowerShell sessions.
Proposed technical implementation details (optional)
The existing implementation of [Microsoft.PowerShell.PSConsoleReadLine]::GetDefaultAddToHistoryOption considers Password a sensitive name and returns MemoryOnly, which prevents PSReadLine from saving the command to the history file. innerAst is a StringConstantExpressionAst with StringConstantType : BareWord. Its parent is a MemberExpressionAst, the grandparent is a CommandExpressionAst, and the great grandparent is a PipelineAst.
I imagine the heuristic could be changed to allow a MemberExpressionAst in which the name of the member is sensitive, if it is not at the left side of an assignment operator like $shield.Password = "12345". The VariableExpressionAst case already checks IsOnLeftSideOfAnAssignment.