File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,31 @@ Set-PSReadLineOption -HistorySearchCursorMovesToEnd
18
18
Set-PSReadlineKeyHandler - Key UpArrow - Function HistorySearchBackward
19
19
Set-PSReadlineKeyHandler - Key DownArrow - Function HistorySearchForward
20
20
21
+ # Being able to search the entirety of your history in a popup makes it
22
+ # really easy to find a command you previously used.
23
+ # Either press F7 to bring up your entire history, or type part of the
24
+ # command line and then press F7 to bring up just the commands that match.
25
+ Set-PSReadlineKeyHandler - Key F7 `
26
+ - BriefDescription History `
27
+ - LongDescription ' Show history' `
28
+ - ScriptBlock {
29
+ $history = [System.Collections.ArrayList ]([System.IO.File ]::ReadAllLines((Get-PSReadlineOption ).HistorySavePath))
30
+ $history.Reverse ()
31
+
32
+ $line = $null
33
+ $cursor = $null
34
+ [PSConsoleUtilities.PSConsoleReadline ]::GetBufferState([ref ]$line , [ref ]$cursor )
35
+ if ($line ) {
36
+ $history = $history -match [regex ]::Escape($line )
37
+ }
38
+
39
+ $command = $history | Get-Unique | Out-GridView - Title History - PassThru
40
+ if ($command ) {
41
+ [PSConsoleUtilities.PSConsoleReadLine ]::RevertLine()
42
+ [PSConsoleUtilities.PSConsoleReadLine ]::Insert($command )
43
+ }
44
+ }
45
+
21
46
# This is an example of a macro that you might use to execute a command.
22
47
# This will add the command to history.
23
48
Set-PSReadlineKeyHandler - Key Ctrl+ B `
You can’t perform that action at this time.
0 commit comments