Skip to content

Instantly share code, notes, and snippets.

@kilasuit
Created September 9, 2021 00:20
Show Gist options
  • Save kilasuit/d30dac3bfa4d8655961dbb52ed001382 to your computer and use it in GitHub Desktop.
Save kilasuit/d30dac3bfa4d8655961dbb52ed001382 to your computer and use it in GitHub Desktop.
helper function to search PSReadline history
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