1
0
mirror of https://github.com/sharkdp/bat synced 2026-06-09 10:03:18 +00:00

73 Commits

Author SHA1 Message Date
Matt Van Horn 66e336bcfb 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.
2026-05-19 04:19:31 -07:00
truffle 138d70fd4c fix(zsh): drop redundant awk pipeline in language completion
`bat --list-languages` already emits each entry in `name:matchers`
form, which is the format `_describe` consumes directly. The previous
awk script split each line on `:` and re-emitted `$1:$2`, which is
byte-identical to the input.

Verified with `diff <(bat --list-languages) <(bat --list-languages |
awk -F: '{ printf("%s:%s\\n", $1, $2) }')` against the current
syntax set.
2026-05-10 14:10:54 +00:00
truffle 5f952066fb fix: only offer language names in zsh tab completion for -l
The previous awk script in `bat.zsh.in` split each line of
`bat --list-languages` on `:` or `,` and emitted every field as a
completion candidate, including the second column. That column lists
file matchers, which can be plain extensions (`rs`), globs (`*.rs`),
absolute paths (`/etc/profile`), or filenames (`Containerfile`). None
of those parse as `-l` arguments, so completing them produces
`unknown syntax` errors.

Switch to splitting on `:` only and emit the language name as the
completion value with the file-matcher list as its description, which
matches the bash completion's behavior.

Closes #3735.
2026-05-10 09:19:54 +00:00
June Kim a0c95618c4 fix: pass --color=never --decorations=never in zsh completions
When BAT_OPTS contains --color=always or --decorations=always, the zsh
completion script's calls to --list-languages and --list-themes produce
ANSI escape codes that corrupt tab completion results.

Pass --color=never --decorations=never explicitly so completion output
is always plain text regardless of user config.

Fixes #3733
2026-05-09 03:35:54 -07:00
YoshKoz f39d63b85d fix(zsh): use newline-splitting for language completions to fix word-splitting on names with spaces
Language names like "HTML (Jinja2)" and "Apache Conf" contain spaces, which
caused $() command substitution to word-split them into garbage tokens. Use
${(f)"$(...)"}  (split on newlines only) to match the pattern already used
for theme completions on line 100.

Fixes #2897
2026-04-27 05:55:48 +03:00
Varun Chawla cc5f782d28 Add word wrapping mode (#3597)
* feat: add word wrapping mode for --wrap flag

* Run `cargo fmt` and add CHANGELOG entry

* Add word wrap tests, update manpage and shell completions

- Add integration tests for word wrapping: basic word boundary breaking,
  fallback to character wrapping for long words, line numbers, and
  short lines that fit without wrapping
- Update manpage to document the new 'word' wrapping mode
- Update bash, fish, zsh, and PowerShell completions with 'word' option
- Avoid unnecessary clone of `line_buf` when word wrap is disabled

* make clippy and cargo fmt happy

---------

Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
2026-03-03 05:18:49 +02:00
mainnebula 167dda63a8 feat: implement --unbuffered mode for streaming input (#3555)
Repurpose the existing --unbuffered/-u flag (previously a POSIX no-op)
to enable unbuffered input reading using fill_buf()/consume() instead
of read_until(b'\n'). This allows partial lines to display immediately
when piping streaming input like `tail -f` into bat.

- Add unbuffered field to Config and InputReader
- Add read_line_unbuffered() using BufRead::fill_buf()/consume()
- Add flush() to OutputHandle, called after each line in unbuffered mode
- Auto-disable line numbers in unbuffered mode to avoid partial line confusion
- Update help text, man page, and shell completions
- Add unit tests and integration tests
2026-02-11 23:27:08 -05:00
dddffgg 3b34b47d55 docs: add --quiet-empty to PowerShell completion 2026-02-01 16:21:38 +08:00
dddffgg 9a5519057c docs: add --quiet-empty to fish completion 2026-02-01 16:21:22 +08:00
dddffgg 93411a96e4 docs: add --quiet-empty to zsh completion 2026-02-01 16:21:05 +08:00
dddffgg bd461afd75 docs: add --quiet-empty to bash completion 2026-02-01 16:20:49 +08:00
Keith Hall af8f0626ac Update PowerShell completions for compatibility with PowerShell v5.1
Modified the PowerShell completion script to replace the null-coalescing operator (`??` - a v7 feature) with a conditional statement compatible with PowerShell v5.1. The script now uses an if-else check for null descriptions in the language completion section.
2025-11-27 21:50:17 +02:00
Koichi Murase 3188a147d8 Use "-o fullquote" and "-o noquote" to escape Bash completions 2025-10-20 19:38:54 +09:00
Koichi Murase 926fbc4b13 Fix indentation of the Bash completion file 2025-10-20 17:59:48 +09:00
Keith Hall 8e90efb2b4 Add missing shell completions for various CLI arguments 2025-10-07 22:30:53 +03:00
Academician c29f1875d3 Add --builtin=pager to readme, completions, and man pages 2025-09-09 16:26:49 -04:00
deflektor d4fc07a347 Update _bat.ps1.in 2025-08-08 06:11:04 +03:00
deflektor 0238473868 Update assets/completions/_bat.ps1.in
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-08 06:11:04 +03:00
deflektor 4363ddf0fb Update assets/completions/_bat.ps1.in
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-08 06:11:04 +03:00
deflektor 43c5fef70a Update assets/completions/_bat.ps1.in
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-08 06:11:04 +03:00
deflektor 7e436e307d Update assets/completions/_bat.ps1.in
changed back to Template

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-08 06:11:04 +03:00
deflektor b4d529402a Update ps1 completion;removed shortcuts from completion;added completion for language, theme and options 2025-08-08 06:11:04 +03:00
Keith Hall da4defad07 Merge branch 'master' into master 2024-11-13 21:59:48 +02:00
volklord 15f2553a3d bat.zsh.in: Remove duplicate word
Remove the duplicate word `disable disable`
2024-11-13 20:30:04 +02:00
Tau Gärtli 89ce060183 Update help, man page and completions 2024-08-18 20:32:59 +02:00
Tau Gärtli bc42149a72 Merge color scheme options into theme / BAT_THEME 2024-08-18 14:59:14 +02:00
Tau Gärtli b9b981f657 Generalize --detect-color-scheme to --color-scheme 2024-08-16 14:14:30 +02:00
Tau Gärtli 9a1bfe946d Update completions and man page 2024-08-16 14:12:23 +02:00
Koichi Murase b1cdc06430 Add --no-* options to Bash/Zsh completions 2024-07-29 12:18:40 +09:00
Koichi Murase 83a15ac05f Add --cache-dir to Fish completion 2024-07-29 12:18:40 +09:00
Koichi Murase 43a77a42f8 Add options present in --help to Bash completion 2024-07-29 12:18:40 +09:00
Oliver Kiddle b43d31b75a Improvements and fixes to zsh completion
* Use correct return status so that approximate completion isn't broken
* Follow zsh conventions on description forms
* Some options can be used multiple times, e.g. -H, -r, --file-name
* Set completion context correctly for the cache subcommand
* Better completion for --map-syntax argument
* Add --nonprintable-notation option
* Correct some of the mutual exclusion lists for options
2023-12-01 11:11:44 +01:00
Maria José Solano 04e7d2a313 fix(completions): add missing fish completions 2023-11-04 08:51:13 +01:00
Anomalocaridid b56021ffa9 make LESSOPEN support opt-in 2023-09-08 06:25:20 +02:00
Anomalocaridid e32ad0b048 Add $LESSOPEN and $LESSCLOSE support (#2444) 2023-09-02 08:48:26 +02:00
Adrián Bíro e155f56484 Clean-up bash comletion
"cword" is unset and even is not used in completion for other shells, so it probably shouldn't be here either. If it for some reason should be there add the directive "# shellcheck disable=SC2034" to the line above it.
2023-05-12 05:59:36 +02:00
cyqsimon b6b9d3a629 Disable completion of cache subcommand (#2399)
* Disable completion of `cache` subcommand

* Fully removed completion code for `cache`

* Add to changelog
2022-12-18 11:46:43 +01:00
Ville Skyttä 2dbc88d3af Improve bash completion escaping
`compopt -o filenames` is a cheap way to accomplish mostly wanted
behavior. However it is semantically incorrect when we are not actually
completing filenames, and has side effects -- for example adds a
trailing slash to candidates matching present dirs.

bash >= 4.1 can `printf -v` to an array index, use it instead where
available.
2022-09-11 21:54:22 +02:00
Ville Skyttä 66edfe5dff Exclude --unbuffered from bash completions
It's a no-op, so there's little reason to suggest it.
2022-09-11 21:54:22 +02:00
Ville Skyttä c816188f97 Add --style argument bash completion 2022-09-11 21:54:22 +02:00
Ville Skyttä 46bf3c1e9a Do not offer bash filename completions with --list-languages/-themes 2022-09-11 21:54:22 +02:00
Ville Skyttä 066701d671 Add --acknowledgements and --ignored-suffix to bash completion 2022-09-11 21:54:22 +02:00
Ville Skyttä e96cdc3b95 Split bash completion option lists over multiple lines, sync sort with --help
For maintainability/diffability.
2022-09-11 21:54:22 +02:00
Z. Grace Moreau 33ba136fa3 fix --pager opts display and add some examples 2022-08-27 16:37:34 +02:00
Z. Grace Moreau f36df73ac1 add a vim modeline
This will cause vim (and other properly-extended editors) to read this
as a fish script file, despite its .fish.in extension.
2022-08-27 16:37:34 +02:00
Z. Grace Moreau d14e0fe292 improve fish completions 2022-08-27 16:37:34 +02:00
Isaac Horvath adea895026 Add a --style=default option (#2119)
* Add a --style=default option

* Added --style=default test and CHANGELOG entry

* Format CHANGELOG.md options with quotes

Co-authored-by: Martin Nordholts <enselic@gmail.com>

* Update help text for '--style'

* Make --style=default the default option

* Update style descriptions: "basic" -> "recommended"

* Add integration test for --style=default as default

* Update clap long help for --style
2022-05-04 21:31:32 +02:00
Martin Nordholts 3c057aa590 Add header-filename and header-filesize where missing 2022-02-27 07:39:22 +01:00
Josh Pencheon ad6cae433a fix Bash completion on macOS (#2074)
* fix Bash completion on macOS

The Homebrew-provided bash-completion is version 1.x,
which doesn't provide _init_completion. We add a standard
shim instead.

* Add entry to CHANGELOG

* Update CHANGELOG.md

Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>

* review: avoid calling _split_longopt repeatedly

Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
2022-02-24 07:57:23 +01:00
NotWearingPants 6fc7ebf37a Add missing style values in fish & zsh completions (#1890) 2021-10-11 19:13:16 +02:00