Skip to content

Commit

Permalink
Set Scheme for history functions (#226)
Browse files Browse the repository at this point in the history
- Add Scheme option
- Use Scheme option in history functions
- Resolves Better default behavior for post fzf 0.32.0 #211
  • Loading branch information
kelleyma49 authored Jun 11, 2023
1 parent fc9e2f3 commit 051a0da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion PSFzf.Base.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ function Invoke-Fzf {
[Alias('i')]
[switch]$CaseInsensitive,
[switch]$CaseSensitive,
[ValidateSet('default','path','history')]
[string]
$Scheme = $null,
[Alias('d')]
[string]$Delimiter,
[switch]$NoSort,
Expand Down Expand Up @@ -341,6 +344,7 @@ function Invoke-Fzf {
if ($PSBoundParameters.ContainsKey('Exact') -and $Exact) { $arguments += '--exact '}
if ($PSBoundParameters.ContainsKey('CaseInsensitive') -and $CaseInsensitive) { $arguments += '-i '}
if ($PSBoundParameters.ContainsKey('CaseSensitive') -and $CaseSensitive) { $arguments += '+i '}
if ($PSBoundParameters.ContainsKey('Scheme') -and ![string]::IsNullOrWhiteSpace($Scheme)) { $arguments += "--scheme=$Scheme "}
if ($PSBoundParameters.ContainsKey('Delimiter') -and ![string]::IsNullOrWhiteSpace($Delimiter)) { $arguments += "--delimiter=$Delimiter "}
if ($PSBoundParameters.ContainsKey('NoSort') -and $NoSort) { $arguments += '--no-sort '}
if ($PSBoundParameters.ContainsKey('ReverseInput') -and $ReverseInput) { $arguments += '--tac '}
Expand Down Expand Up @@ -776,7 +780,7 @@ function Invoke-FzfPsReadlineHandlerHistory {
$fileHist.Add($_,$true)
$_
}
} | Invoke-Fzf -Query "$line" -Bind ctrl-r:toggle-sort | ForEach-Object { $result = $_ }
} | Invoke-Fzf -Query "$line" -NoSort -Bind ctrl-r:toggle-sort -Scheme history | ForEach-Object { $result = $_ }
}
catch
{
Expand Down
4 changes: 2 additions & 2 deletions PSFzf.Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ function Invoke-FuzzyFasd() {
#.ExternalHelp PSFzf.psm1-help.xml
function Invoke-FuzzyHistory() {
if (Get-Command Get-PSReadLineOption -ErrorAction Ignore) {
$result = Get-Content (Get-PSReadLineOption).HistorySavePath | Invoke-Fzf -Reverse -NoSort
$result = Get-Content (Get-PSReadLineOption).HistorySavePath | Invoke-Fzf -Reverse -NoSort -Scheme history
}
else {
$result = Get-History | ForEach-Object { $_.CommandLine } | Invoke-Fzf -Reverse -NoSort
$result = Get-History | ForEach-Object { $_.CommandLine } | Invoke-Fzf -Reverse -NoSort -Scheme history
}
if ($null -ne $result) {
Write-Output "Invoking '$result'`n"
Expand Down

0 comments on commit 051a0da

Please sign in to comment.