From bc78270318a0eaf4a16fad6850bbb35ecd530e9d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 17:34:24 +0000 Subject: [PATCH 1/2] Fix: Add --no-config to bat preview commands This change adds the `--no-config` flag to all `bat` invocations within the `PsFzfTabExpansion-Preview.ps1` script. This prevents your user-specific `bat` configurations (e.g., custom themes or styles) from interfering with or breaking the preview functionality in PSFzf's tab expansion. The following `bat` commands were modified: - Directory preview (git log) - File preview - PowerShell command help preview I manually tested and confirmed that `bat` does not load user configurations when the `--no-config` flag is present. Fixes https://github.com/kelleyma49/PSFzf/issues/308 --- helpers/PsFzfTabExpansion-Preview.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/PsFzfTabExpansion-Preview.ps1 b/helpers/PsFzfTabExpansion-Preview.ps1 index f6fa91a..b9137dd 100644 --- a/helpers/PsFzfTabExpansion-Preview.ps1 +++ b/helpers/PsFzfTabExpansion-Preview.ps1 @@ -23,7 +23,7 @@ if (Test-Path $path -PathType Container) { Write-Output "" # extra separator before git status Push-Location $path if ($ansiCompatible -and $(Get-Command bat -ErrorAction Ignore)) { - git log -1 2> $null | bat "--style=changes" --color always + git log -1 2> $null | bat --no-config "--style=changes" --color always } else { git log -1 2> $null @@ -35,7 +35,7 @@ if (Test-Path $path -PathType Container) { elseif (Test-Path $path -PathType leaf) { # use bat (https://github.com/sharkdp/bat) if it's available: if ($ansiCompatible -and $(Get-Command bat -ErrorAction Ignore)) { - bat "--style=numbers,changes" --color always $path + bat --no-config "--style=numbers,changes" --color always $path } else { Get-Content $path @@ -46,7 +46,7 @@ elseif (($cmdResults = Get-Command $Item -ErrorAction Ignore)) { if ($cmdResults) { if ($cmdResults.CommandType -ne 'Application') { if ($ansiCompatible -and $(Get-Command bat -ErrorAction Ignore)) { - Get-Help $Item | bat --language=markdown --color always --style=plain + Get-Help $Item | bat --no-config --language=markdown --color always --style=plain } else { From 1452a1323a1788f0b10fc8a490c38508bb830a94 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 30 May 2025 17:41:16 +0000 Subject: [PATCH 2/2] Fix: Add --no-config to all bat preview commands This change adds the `--no-config` flag to all identified `bat` invocations used for generating previews within the PSFzf module. This prevents your user-specific `bat` configurations (e.g., custom themes or styles) from interfering with or breaking the preview functionality. The following files and functions were modified: - `helpers/PsFzfTabExpansion-Preview.ps1`: - Directory preview (git log) - File preview - PowerShell command help preview - `PSFzf.Functions.ps1`: - `Invoke-PsFzfRipgrep` function's fzf preview command - `helpers/PsFzfTabExpansion-Parameter.ps1`: - PowerShell command parameter help preview Manual testing confirmed that `bat` does not load user configurations when the `--no-config` flag is present in all these locations. Fixes https://github.com/kelleyma49/PSFzf/issues/308 --- PSFzf.Functions.ps1 | 2 +- helpers/PsFzfTabExpansion-Parameter.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PSFzf.Functions.ps1 b/PSFzf.Functions.ps1 index 6f0190e..4c23f28 100644 --- a/PSFzf.Functions.ps1 +++ b/PSFzf.Functions.ps1 @@ -349,7 +349,7 @@ function Invoke-PsFzfRipgrep() { prompt = 'ripgrep> ' delimiter = ':' header = '? CTRL-R (Ripgrep mode) ? CTRL -F (fzf mode) ?' - preview = 'bat --color=always {1} --highlight-line {2}' + preview = 'bat --no-config --color=always {1} --highlight-line {2}' 'preview-window' = 'up,60%,border-bottom,+{2}+3/3,~3' } diff --git a/helpers/PsFzfTabExpansion-Parameter.ps1 b/helpers/PsFzfTabExpansion-Parameter.ps1 index 4f77e40..cd3d50a 100644 --- a/helpers/PsFzfTabExpansion-Parameter.ps1 +++ b/helpers/PsFzfTabExpansion-Parameter.ps1 @@ -18,7 +18,7 @@ if ([System.Management.Automation.Cmdlet]::CommonParameters.Contains($parameter) } else { if ($ansiCompatible -and $(Get-Command bat -ErrorAction Ignore)) { - Get-Help -Name $Command -Parameter $parameter | bat --language=markdown --color always --style=plain + Get-Help -Name $Command -Parameter $parameter | bat --no-config --language=markdown --color always --style=plain } else { Get-Help -Name $Command -Parameter $parameter