1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-16 15:53:18 +00:00
Commit Graph

1150 Commits

Author SHA1 Message Date
Justin Su de396794cf Add Ghostty syntax mapping 2026-05-18 03:29:12 -04:00
curious-rabbit 3be4e30e00 improve patch 2026-05-06 10:58:02 +02:00
curious-rabbit c437ad4d27 fix command injection in LESS template 2026-05-06 00:46:35 +02:00
Keith Hall f7b84a3b41 Merge branch 'master' into makefile-syntax-for-justfiles 2026-05-02 13:56:45 +03:00
Keith Hall 12ee94f530 Merge branch 'master' into list-themes-term-probe-fix 2026-04-30 14:13:47 +03:00
Keith Hall 54bfc33248 Merge branch 'master' into fix/lessclose-nonzero-warning 2026-04-30 08:10:40 +03:00
zach valenta 5bf932d511 Merge branch 'master' into makefile-syntax-for-justfiles 2026-04-28 14:41:15 -04:00
Keith Hall 5977245a23 Merge branch 'master' into fix/lessclose-nonzero-warning 2026-04-28 19:24:00 +03:00
Keith Hall 8c8ed90d6d Merge branch 'master' into master 2026-04-27 22:20:33 +03:00
lawrence3699 64567c4819 Propagate initial input read errors 2026-04-28 01:11:48 +10:00
Ish West c3df0e6a88 Fixed a bug with hardcoded terminal probing when --list-themes is called 2026-04-25 17:37:36 +02:00
curious-rabbit 71c894e843 santize filenames 2026-04-20 14:25:49 +02:00
Asish Kumar a9137fab05 Support BAT_WIDTH as an alias for --terminal-width
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
2026-04-12 01:12:55 +05:30
Asish Kumar 2459aa9404 Detect ZIP archives as binary content 2026-04-10 14:35:33 +00:00
Lucas Trzesniewski c64b6761fe Add .NET slnx extension
This is the new XML-based format for solution files.
2026-04-07 23:25:40 +02:00
Keith Hall 3e4169b8c3 cargo fmt 2026-03-31 22:35:21 +03:00
Keith Hall ba223289ce Update --diagnostic output with detected terminal color scheme type 2026-03-31 22:23:10 +03:00
Keith Hall abab6533e4 Update --diagnostic output with BAT_THEME_LIGHT/DARK env vars 2026-03-31 22:22:31 +03:00
Weixie Cui 7ff1fb3278 fix: warn when $LESSCLOSE fails, not when it succeeds
The Drop cleanup for Preprocessed inverted the exit-status check, so bat
emitted a warning when LESSCLOSE exited successfully and stayed silent on
failure. Align the condition with the intended behavior.
2026-03-26 11:10:58 +08:00
copilot-swe-agent[bot] 87e043b91c Add Home/End key bindings to builtin minus pager
Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com>
2026-03-24 21:33:43 +02:00
Keith Hall 7a9c6e0de5 Merge branch 'master' into patch-2 2026-03-22 17:47:24 +02:00
Keith Hall 1e36873704 Merge branch 'master' into feat/diff-plain-compatibility 2026-03-21 16:21:56 +02:00
Matt Van Horn e60875ac12 fix: gate Changes component on git feature flag
When bat is built without the `git` feature, `StyleComponent::Changes`
is not available. Add `#[cfg(feature = "git")]` guard so `--diff --plain`
works in both configurations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 15:27:10 -07:00
Keith Hall 66eece4e2c Merge branch 'master' into patch-2 2026-03-20 23:57:19 +02:00
Keith Hall 3767f15c2a improvements from PR review
fix documentation about syntax mappings
2026-03-20 23:34:38 +02:00
Eyüp Can Akman fc94a0ec49 fix: account for caret notation width in text wrapping
Control characters displayed in caret notation (e.g. ^@ for NUL)
occupy 2 terminal columns, but the width calculation treated them
as 0-width. Add a char_width() helper that returns 2 for control
characters, fixing incorrect line wrapping with --binary=as-text.

Fixes #3631
2026-03-20 22:28:39 +02:00
Matt Van Horn 2a3ed948ec feat: preserve change markers when combining --diff with --plain
When --plain is set (via CLI or config file), --diff output loses all
visual markers, making it indistinguishable from plain text. The diff
line filtering still works, but without Changes markers or Snip
separators the output is not useful.

Automatically include Changes and Snip style components when --diff is
active alongside --plain. This preserves the --plain intent (no grid,
no header, no line numbers) while keeping diff output readable.

Closes #3630
2026-03-19 21:35:48 -07:00
Keith Hall c6e661d80b cargo fmt 2026-03-18 22:25:07 +02:00
Keith Hall 031ba0953a Merge branch 'master' into patch-2 2026-03-18 22:17:18 +02:00
copilot-swe-agent[bot] 2a29802dd5 Refactor: string-or-struct matcher syntax, Case enum, remove case_sensitive_mappings table
Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com>
2026-03-18 22:16:50 +02:00
Víctor González Prieto a4e853c4fa Map ignore files to Git Ignore syntax
This would catch any dotfiles that end in "ignore", but not `.ignore`

Set as a lower priority rule (90 vs the usual 50) because it's a blanket
assignation. If there are conflict with other, more specific rules,
those will take precedence.
2026-03-18 21:58:23 +02:00
Keith Hall 22c38b6fcb Merge remote-tracking branch 'origin/master' into patch-2 2026-03-18 05:19:21 +02:00
Víctor González Prieto a1917275cd Add syntax mappings for GCloud CLI config files
> .boto => INI

I was uninstalling gcloud-cli and the docs said to review the contents
of ~/.boto [^1].

`bat` doesn't recognize it but it's just an INI-like file to configure
gsutil [^2].

I took the chance to add a few more mappings for other GCloud config
files without extension...

> .gcloudignore => Git Ignore

This one's self-explanatory, but it's documented in [^3].

Makes me wonder if we could just do a blanket `Git Ignore = ".?*ignore"`
for every kind of ignore file. For instance, `bat` doesn't catch
.dockerignore either.

> **/gcloud/configurations/config_* => INI

These are configuration files for each different profile you have
configured for the gcloud-cli [^4].

They're named like "config_default" or "config_<name>", without a
file extension, but they are also INI syntax [^5][^6].

[^1]: https://docs.cloud.google.com/sdk/docs/uninstall-cloud-sdk
[^2]: https://docs.cloud.google.com/storage/docs/boto-gsutil
[^3]: https://docs.cloud.google.com/sdk/gcloud/reference/topic/gcloudignore
[^4]: https://docs.cloud.google.com/sdk/docs/configurations
[^5]: https://stackoverflow.com/questions/74290882/return-active-gcp-project-name-programatically-for-both-local-dev-and-deployed-c/7^4292151#74292151
[^6]: https://stackoverflow.com/questions/49212350/where-does-gcloud-store-its-defaults/49256835#49256835
2026-03-17 20:51:23 +01:00
Keith Hall 884765bdeb Merge remote-tracking branch 'origin/master' into patch-2 2026-03-14 09:21:19 +02:00
Keith Hall 56fe0fa226 Add case-sensitive glob support to syntax mapping
to allow us to map `BUILD` case sensitively to Python for Skylark
2026-03-14 09:18:56 +02:00
zachvalenta 652d50e92e Makefile syntax for justfiles 2026-03-08 21:06:19 -04:00
Rizky Mirzaviandy Priambodo f49641a6c3 Fix syntax highlighting for symlinked files by resolving target path
When a symlink name has no recognizable extension (e.g. Aliases/0install),
syntax detection fails because the symlink path doesn't match any syntax.
The target file may have a recognizable extension (e.g. Formula/zero-install.rb)
but was never consulted.

When path-based syntax detection fails with UndetectedSyntax, canonicalize
the path to resolve symlinks and retry detection with the target path.
This preserves existing behavior where the symlink path itself matches
(e.g. .ssh/config), since the original path is tried first.

Closes #1001
2026-03-09 00:01:09 +07:00
Rizky Mirzaviandy Priambodo 9cce9e04d2 Fix BAT_CONFIG_DIR pointing at system config dir causing duplicate flag errors
When BAT_CONFIG_DIR is set to the system config directory (e.g. /etc/bat),
both system_config_file() and config_file() resolve to /etc/bat/config.
The config file was read twice, causing clap errors for non-repeatable flags
like --italic-text.

Skip the user config read when it resolves to the same file as the system
config, using canonicalization to also handle symlinks.

Closes #3589
2026-03-08 12:20:27 +07:00
Rizky Mirzaviandy Priambodo 844bfded50 Add --fallback-syntax for undetected files (#3617)
* feat(cli): add fallback syntax option

Expose a new fallback syntax CLI option so users can opt into syntax highlighting only when auto-detection fails.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* feat(syntax): apply fallback only after detection fails

Use the fallback syntax only when path and first-line detection fail, preserving existing behavior for detected files and explicit language selection.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* test(cli): cover fallback syntax behavior

Add integration coverage for fallback syntax usage, precedence with --language, and no-op behavior when syntax is already detected; update help snapshots for the new option.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

* docs(changelog): document fallback syntax option

Record the new fallback syntax feature in the unreleased changelog section.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

---------

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-08 05:18:29 +02:00
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