@@ -61,7 +61,14 @@ public enum AddToHistoryOption
6161 {
6262 SkipAdding ,
6363 MemoryOnly ,
64- MemoryAndFile
64+ MemoryAndFile ,
65+ SQLite
66+ }
67+
68+ public enum HistoryType
69+ {
70+ Text ,
71+ SQLite
6572 }
6673
6774 public enum PredictionSource
@@ -106,6 +113,12 @@ public class PSConsoleReadLineOptions
106113
107114 public const string DefaultContinuationPrompt = ">> " ;
108115
116+ /// <summary>
117+ /// The default history format is text. The SQLite is experimental.
118+ /// It is not recommended to use it for production yet.
119+ /// </summary>
120+ public const HistoryType DefaultHistoryType = HistoryType . Text ;
121+
109122 /// <summary>
110123 /// The maximum number of commands to store in the history.
111124 /// </summary>
@@ -201,6 +214,7 @@ public PSConsoleReadLineOptions(string hostName, bool usingLegacyConsole)
201214 {
202215 ResetColors ( ) ;
203216 EditMode = DefaultEditMode ;
217+ HistoryType = DefaultHistoryType ;
204218 ContinuationPrompt = DefaultContinuationPrompt ;
205219 ContinuationPromptColor = Console . ForegroundColor ;
206220 ExtraPromptLineCount = DefaultExtraPromptLineCount ;
@@ -235,6 +249,13 @@ public PSConsoleReadLineOptions(string hostName, bool usingLegacyConsole)
235249 "PowerShell" ,
236250 "PSReadLine" ,
237251 historyFileName ) ;
252+ SqliteHistorySavePath = System . IO . Path . Combine (
253+ Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ,
254+ "Microsoft" ,
255+ "Windows" ,
256+ "PowerShell" ,
257+ "PSReadLine" ,
258+ hostName + "_history.db" ) ;
238259 }
239260 else
240261 {
@@ -336,6 +357,7 @@ public object ContinuationPromptColor
336357 /// that do invoke the script block - this covers the most useful cases.
337358 /// </summary>
338359 public HashSet < string > CommandsToValidateScriptBlockArguments { get ; set ; }
360+ public HistoryType HistoryType { get ; set ; } = HistoryType . Text ;
339361
340362 /// <summary>
341363 /// When true, duplicates will not be recalled from history more than once.
@@ -375,6 +397,11 @@ public object ContinuationPromptColor
375397 /// The path to the saved history.
376398 /// </summary>
377399 public string HistorySavePath { get ; set ; }
400+
401+ /// <summary>
402+ /// The path to the SQLite history database.
403+ /// </summary>
404+ public string SqliteHistorySavePath { get ; set ; }
378405 public HistorySaveStyle HistorySaveStyle { get ; set ; }
379406
380407 /// <summary>
@@ -656,6 +683,20 @@ public EditMode EditMode
656683 [ AllowEmptyString ]
657684 public string ContinuationPrompt { get ; set ; }
658685
686+ [ Parameter ]
687+ public HistoryType HistoryType
688+ {
689+ get => _historyType . GetValueOrDefault ( ) ;
690+ set
691+ {
692+ _historyType = value ;
693+ _historyTypeSpecified = true ;
694+ }
695+ }
696+
697+ public HistoryType ? _historyType = HistoryType . Text ;
698+ internal bool _historyTypeSpecified ;
699+
659700 [ Parameter ]
660701 public SwitchParameter HistoryNoDuplicates
661702 {
0 commit comments