1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-17 16:03:19 +00:00
Commit Graph

1110 Commits

Author SHA1 Message Date
Matei6942 ab80bd9717 feat(syntax): add support for hidden_file_extensions (#3613)
* feat(syntax): add support for hidden_file_extensions
2026-03-06 20:14:20 +02: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
Nicolas fd67095cff Fix panic in BuiltinPager drop when pager thread panics
The Drop impl for OutputType::BuiltinPager calls
handle.take().unwrap().join().unwrap() which panics if the
pager thread itself panicked. In Drop, this causes a double
panic (abort).

Replace with if-let and discard the join result, matching the
pattern used for OutputType::Pager which also uses let _ =.

Reported in #3449 where BAT_PAGER=builtin with --help
causes the pager thread to fail.

Fixes #3449
2026-03-02 04:12:50 +09:00
Keith Hall 74de075748 Merge branch 'master' into fix/warn-missing-pager 2026-02-20 20:37:07 +02:00
Ian Maloney 62b0388236 remove code comments 2026-02-20 06:12:14 +00:00
Ian Maloney 790bed3a2d fix: respect --wrap=never flag when paging is enabled
When output is piped to a pager, the wrapping_mode logic was not checking the explicit --wrap=never flag and would always default to NoWrapping(false). This meant the -S flag was not passed to less, causing lines to wrap despite the user's explicit request.

The fix prioritizes explicit CLI flags (--wrap=never, --chop-long-lines) over the interactive_output-based logic, ensuring they are always respected.

Fixes #3587
2026-02-20 06:04:14 +00:00
Ian Maloney 319811df01 fix test: use builtin pager instead of less, revert to warn for all missing pagers 2026-02-20 00:09:02 +00:00
Ian Maloney 2c1a8caadd simplify: just never warn for less (universal default) 2026-02-19 22:49:02 +00:00
Ian Maloney a240aa4afd never warn for missing 'less' pager (common default) 2026-02-19 22:21:17 +00:00
Ian Maloney 00e38cd056 only warn for explicitly configured pagers, not defaults 2026-02-19 22:01:58 +00:00
Ian Maloney 335eff51f3 fix type error, pager.bin is already a string 2026-02-19 21:44:47 +00:00
Ian Maloney d04b960c05 warn when pager is missing instead of silently falling back
when a configured pager (via BAT_PAGER, PAGER, or --pager) is not found,
bat now shows a warning message before falling back to stdout. this helps
users understand why their pager isn't running and makes it obvious when
there's a typo or PATH issue.

fixes issue #2904
2026-02-19 21:29:59 +00: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 cb8b637574 fix(cache): allow --help flag for cache subcommand (#3580)
* fix(cache): allow --help flag for cache subcommand

* docs: add changelog entry for cache --help fix
2026-02-09 05:06:40 +02:00
Keith Hall eb724f2dc4 Merge branch 'master' into master 2026-02-03 22:27:30 +02:00
dddffgg 783acbc83d feat: implement quiet_empty behavior in printer 2026-01-31 16:42:28 +08:00
dddffgg 6f0a61cef9 feat: wire up quiet_empty config in app 2026-01-31 16:41:46 +08:00
dddffgg 53a10e0b0a feat: add --quiet-empty CLI flag 2026-01-31 16:41:13 +08:00
dddffgg 626154317f feat: add quiet_empty config option 2026-01-31 16:40:59 +08:00
Cedric Erdelen f6f1f18e9c remove trailing whitespace 2026-01-28 19:59:10 +01:00
cerdelen 69a2ffbdac Update src/config.rs
Co-authored-by: Keith Hall <keith-hall@users.noreply.github.com>
2026-01-28 19:48:02 +01:00
Cedric Erdelen 6b8decf2a4 Small typo fixes 2026-01-28 14:12:32 +01:00
Hakil ad608014d9 fix issue #3526 (#3529) 2025-12-23 19:08:38 +02:00
ANCHAL fca5502f21 Fix bat crash with BusyBox less on Windows
- Retrieve less version earlier in src/output.rs.
- Skip -K argument if less is detected as BusyBox version.
- Reuses the version check for the existing --no-init logic.
- Fixes #3518.
2025-12-16 22:25:27 +05:30
Alex Kirk 4549ab3f22 Move the strip_overstrike check 2025-12-11 06:06:07 +01:00
Alex Kirk 629a8968fc Remove unnecessary code change 2025-12-11 05:54:30 +01:00
Alex Kirk de414ed631 Limit overstrike stripping to man pages and help 2025-12-11 05:49:46 +01:00
Alex Kirk f97f9ebf03 Remove double backspace scan 2025-12-11 05:49:46 +01:00
Alex Kirk 64a4b204a2 Only strip overstrike when a syntax highlighting theme is used 2025-12-11 05:49:46 +01:00
Alex Kirk 5fb8a25c30 Performance optimization 2025-12-11 05:49:46 +01:00
Alex Kirk 51bdaa5f88 Strip overstriking to better support man pages 2025-12-11 05:49:46 +01:00
Keith Hall b7dd88eafd Support custom assets (themes) when displaying help output 2025-12-10 22:30:01 +02:00
Keith Hall 1796324531 Fix --help --pager=builtin
Previously it still used less
2025-12-04 21:53:45 +02:00
Keith Hall 0e469634a3 return None for get_pager_executable when builtin pager is used (#3498) 2025-12-01 20:02:55 +00:00
Keith Hall 579d371378 Ensure --help respects valid config file
While still ignoring ignoring invalid arguments in the config
2025-12-01 05:30:05 +02:00
Cedric Staniewski a6e0057c12 Add syntax mapping for podman's artifact quadlet files 2025-11-30 14:18:12 +02:00
Keith Hall 3755f788ca Improve -n detection to handle combined flags correctly
Updated the logic to correctly handle combined short flags like -pn and -np.
The -n flag is only honored when it's either:
1. A standalone flag (-n or --number)
2. The last flag in a combined form that includes -p (e.g., -pn), or
3. In a combined form without -p (e.g., -An)

This ensures that -np (where -p overrides -n) correctly produces plain output,
while -pn (where -n overrides -p) produces line numbers.
2025-11-30 05:02:13 +02:00
Keith Hall abc7261488 Fix -n flag to show line numbers in loop-through mode
When the -n/--number flag is passed on the command line, bat now shows
line numbers even when piping output to another process (loop-through
mode), similar to how `cat -n` behaves.

This change detects if -n or --number was passed on the CLI (before
merging with config file and environment variables) and disables
loop-through mode in that case, allowing the InteractivePrinter to
add line numbers.

The existing behavior is preserved:
- Styles from config/env are still ignored when piping (unless --decorations=always is set)
- Only the -n flag from CLI enables line numbers in piped mode
- -p and --style options from CLI do not disable loop-through mode
2025-11-30 05:02:13 +02:00
Keith Hall 7d37325c19 Fix to not show style decorations in auto mode when piping 2025-11-30 05:02:13 +02:00
Muntasir Mahmud 70ec3fc24e feat: add paging to '-h' and '--help' (#3478)
* feat: add paging to '-h' and '--help'

Fixes #1587
2025-11-23 20:10:56 +00:00
Keith Hall cfe49779fa Merge branch 'master' into fix/list-themes-pager-hang 2025-11-15 15:41:07 +02:00
cyqsimon f5a934c213 Update quadlet syntax mapping to include *.{build,pod} files 2025-11-13 13:44:24 +08:00
Abhinav Diwakar 24813db49f Merge branch 'master' into fix/list-themes-pager-hang 2025-11-06 23:26:06 +05:30
Benjamin A. Beasley ce856dbba7 Update etcetera to 0.11; no longer depend on home; MSRV 1.87
Release 0.11 of `etcetera` requires MSRV 1.87, in which
`std::env::home_dir` is no longer deprecated,
https://github.com/rust-lang/rust/pull/137327.

Update to that MSRV and to `etcetera`, and drop the dependency on the
`home` crate just as `etcetera` 0.11 did.
2025-11-03 19:06:33 +01:00
abhinavcool42 8b09724420 change imports 2025-11-02 11:55:30 +05:30
abhinavcool42 2af7be1b65 fix prefix 2025-11-02 11:51:00 +05:30
abhinavcool42 9456f7d8cd list-themes buffer added 2025-11-02 11:31:07 +05:30
abhinavcool42 1852dea96a Fix --list-themes pager init so less stays interactive 2025-10-30 18:42:35 +05:30
abhinavcool42 6a99915afe fix --list-themes hang 2025-10-28 16:10:32 +05:30
Louis Maddox 52a792d46f fix: allow hyphen values to -r/--line-range
via #2944
2025-10-19 21:24:59 +01:00