mirror of
https://github.com/sharkdp/bat.git
synced 2026-10-30 10:06:12 +00:00
fix(completions): force --no-paging on bat invocations in completion scripts (#3760)
Every shell completion script (bash, zsh, fish, PowerShell) shells out to bat to enumerate languages/themes for tab completion candidates. If the user has wired bat into LESSOPEN (e.g. LESSOPEN='|-bat -f -pp %s'), bat's normal pager auto-detection can engage when stdout looks like a terminal at completion time and reflect ANSI escape sequences back into the candidate list. The result is the issue's reproducer: tab completion expands 'Per' to '\033[38;2;248;248;242mPerl' instead of 'Perl'. The list-languages/list-themes calls are always meant to be machine- readable, so they should never page. Pass --no-paging explicitly to every bat invocation inside the four completion files. The flag is the public alias for --paging=never (already documented in bat --help) and is the same form completion scripts elsewhere in the codebase use. Touches the four completion files only; no production code changes.
This commit is contained in:
5 files changed
+14
-13
No files matched your search
Vendored
+3
-3
@@ -80,7 +80,7 @@ _bat() {
|
||||
-l | --language)
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=($(compgen -W "$(
|
||||
"$1" --list-languages | while IFS=: read -r lang _; do
|
||||
"$1" --no-paging --list-languages | while IFS=: read -r lang _; do
|
||||
printf "%s\n" "$lang"
|
||||
done
|
||||
)" -- "$cur"))
|
||||
@@ -150,14 +150,14 @@ _bat() {
|
||||
;;
|
||||
--theme)
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --list-themes)" -- "$cur"))
|
||||
COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --no-paging --list-themes)" -- "$cur"))
|
||||
__bat_escape_completions
|
||||
return 0
|
||||
;;
|
||||
--theme-dark | \
|
||||
--theme-light)
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur"))
|
||||
COMPREPLY=($(compgen -W "$("$1" --no-paging --list-themes)" -- "$cur"))
|
||||
__bat_escape_completions
|
||||
return 0
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user