-HistoryNoDuplicates does not have any effect
See original GitHub issueI have Set-PSReadLineOption -HistoryNoDuplicates
in my profile file, and Get-PSReadlineOption
shows HistoryNoDuplicates : True
. But duplicated entries are being added to the ConsoleHost_history.txt
file. I’m using version 1.0.0.13
. The following is all the options I have for PSReadLine:
Import-Module PSReadLine
Set-PSReadLineOption -HistoryNoDuplicates
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally
Set-PSReadLineOption -MaximumHistoryCount 4000
# history substring search
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# Tab completion
Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function Complete
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# automatic quotation
Set-PSReadlineKeyHandler -Chord 'Oem7','Shift+Oem7' `
-BriefDescription SmartInsertQuote `
-LongDescription "Insert paired quotes if not already on a quote" `
-ScriptBlock {
param($key, $arg)
$line = $null
$cursor = $null
[PSConsoleUtilities.PSConsoleReadline]::GetBufferState([ref]$line, [ref]$cursor)
if ($line[$cursor] -eq $key.KeyChar) {
# Just move the cursor
[PSConsoleUtilities.PSConsoleReadline]::SetCursorPosition($cursor + 1)
}
else {
# Insert matching quotes, move cursor to be in between the quotes
[PSConsoleUtilities.PSConsoleReadline]::Insert("$($key.KeyChar)" * 2)
[PSConsoleUtilities.PSConsoleReadline]::GetBufferState([ref]$line, [ref]$cursor)
[PSConsoleUtilities.PSConsoleReadline]::SetCursorPosition($cursor - 1)
}
}
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Set-PSReadLineOption (PSReadLine) - PowerShell
The scriptblock returns $false if the command started with git . This has the same effect as returning the SkipAdding AddToHistory enum. If...
Read more >Powershell history isn't persistent anymore
As noted in my question, as a workaround I currently use Import-Module PSReadLine in my profile file, which I access via notepad $PROFILE...
Read more >windows 10 - How to remove command duplicates?
I tried to check the Discard Old Duplicates box in Properties/Options, but this did not work. How do I turn off duplicate commands?...
Read more >How to change colors of text and background in ...
A full sequence to set both foreground and background using RGB syntax would be something like @{ "Selection" = "$([char]0x1b)[48;2;255;0;0m$([ ...
Read more >Why do I have duplicates in my zsh history?
It is ignoring them if they are one after the other like histignoredups but AFAIK, my configuration should ignore any and all. >...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lzybkr should
Set-PSReadLineOption -HistoryNoDuplicates
be a default?Shared history relies on the file size to know when to reread history. Trimming history would break that, so another mechanism would be needed to notify other sessions that new history was added.
This would actually be a good thing to add - I just never got around to it.
If I spend any time on history, I’m more likely to replace the simple text file with a sqlite database and would design the schema so duplicates are impossible to add.