Created
September 9, 2021 00:20
-
-
Save kilasuit/d30dac3bfa4d8655961dbb52ed001382 to your computer and use it in GitHub Desktop.
helper function to search PSReadline history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Search-History { | |
| <# | |
| .Synopsis | |
| Will do this sometime later | |
| .Example | |
| Search-History | |
| #> | |
| [CmdletBinding()] | |
| param ( | |
| [parameter(Mandatory = $true)] | |
| [String]$Command, | |
| [Parameter()] | |
| [Switch]$line | |
| ) | |
| If ($line) | |
| { (Select-String -Path ((Get-PSReadLineOption).HistorySavePath) -Pattern $Command).Line } | |
| else | |
| { (Select-String -Path ((Get-PSReadLineOption).HistorySavePath) -Pattern $Command) } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment