PSReadLine history doesn't load

1.2k views Asked by At

I tried to use psreadline today. There is something i don't understand is the history command.

When I run

Set-PSReadLineOption -PredictionSource 

The history suggestions start showing up.

I close the terminal ps, open it again, no history suggestions there until i run the command again.

What do I miss?

1

There are 1 answers

0
postanote On BEST ANSWER

If this is the only command you are using...

Set-PSReadLineOption -PredictionSource

.. then that is not complete.

As per the Powershell docs here: MS Docs | PSReadLine

-PredictionSource
Specifies the source for PSReadLine to get predictive suggestions.

Valid values are:

None: disable the predictive suggestion feature
History: get predictive suggestions from history only

So you have to tell it what you want:

Set-PSReadLineOption -PredictionSource History

or

Set-PSReadLineOption -PredictionSource None

The latter is the default if you don't tell it. Just put the former in all your console profiles.

Get-PSReadLineOption
<#
EditMode                               : Windows
AddToHistoryHandler                    : System.Func`2[System.String,System.Object]
HistoryNoDuplicates                    : True
HistorySavePath                        : C:\Users\WDAGUtilityAccount\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
...
PredictionSource                       : None
...
#>

Be sure to read up on ...

Set-PSReadLineOption -HistorySaveStyle

... and its options as well.