1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 10:52:24 +01:00

Merge branch 'master' into master

This commit is contained in:
John Cavanaugh
2025-08-13 23:27:26 -07:00
committed by GitHub
21 changed files with 369 additions and 171 deletions

View File

@@ -1,23 +0,0 @@
# This workflow triggers auto-merge of any PR that dependabot creates so that
# PRs will be merged automatically without maintainer intervention if CI passes
name: Auto-merge dependabot PRs
on:
pull_request_target:
types: [opened]
jobs:
auto-merge:
if: github.repository == 'sharkdp/bat' && startsWith(github.head_ref, 'dependabot/')
runs-on: ubuntu-latest
environment:
name: auto-merge
url: https://github.com/sharkdp/bat/blob/main/.github/workflows/Auto-merge-dependabot-PRs.yml
env:
GITHUB_TOKEN: ${{ secrets.AUTO_MERGE_GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- run: |
gh pr review ${{ github.event.pull_request.number }} --comment --body "If CI passes, this dependabot PR will be [auto-merged](https://github.com/sharkdp/bat/blob/main/.github/workflows/Auto-merge-dependabot-PRs.yml) 🚀"
- run: |
gh pr merge --auto --squash ${{ github.event.pull_request.number }}

8
.gitmodules vendored
View File

@@ -113,9 +113,6 @@
[submodule "assets/syntaxes/DotENV"] [submodule "assets/syntaxes/DotENV"]
path = assets/syntaxes/02_Extra/DotENV path = assets/syntaxes/02_Extra/DotENV
url = https://github.com/zaynali53/DotENV url = https://github.com/zaynali53/DotENV
[submodule "assets/syntaxes/hosts"]
path = assets/syntaxes/02_Extra/hosts
url = https://github.com/brandonwamboldt/sublime-hosts
[submodule "assets/syntaxes/ssh-config"] [submodule "assets/syntaxes/ssh-config"]
path = assets/syntaxes/02_Extra/ssh-config path = assets/syntaxes/02_Extra/ssh-config
url = https://github.com/robballou/sublimetext-sshconfig.git url = https://github.com/robballou/sublimetext-sshconfig.git
@@ -177,7 +174,7 @@
url = https://github.com/euler0/sublime-glsl url = https://github.com/euler0/sublime-glsl
[submodule "assets/syntaxes/02_Extra/Nginx"] [submodule "assets/syntaxes/02_Extra/Nginx"]
path = assets/syntaxes/02_Extra/Nginx path = assets/syntaxes/02_Extra/Nginx
url = https://github.com/brandonwamboldt/sublime-nginx url = https://github.com/SublimeText/nginx
[submodule "assets/syntaxes/02_Extra/Apache"] [submodule "assets/syntaxes/02_Extra/Apache"]
path = assets/syntaxes/02_Extra/Apache path = assets/syntaxes/02_Extra/Apache
url = https://github.com/colinta/ApacheConf.tmLanguage url = https://github.com/colinta/ApacheConf.tmLanguage
@@ -278,3 +275,6 @@
[submodule "assets/syntaxes/02_Extra/SmartVHDL"] [submodule "assets/syntaxes/02_Extra/SmartVHDL"]
path = assets/syntaxes/02_Extra/SmartVHDL path = assets/syntaxes/02_Extra/SmartVHDL
url = https://github.com/TheClams/SmartVHDL url = https://github.com/TheClams/SmartVHDL
[submodule "assets/syntaxes/02_Extra/hosts"]
path = assets/syntaxes/02_Extra/hosts
url = https://github.com/tijn/hosts.tmLanguage

View File

@@ -16,6 +16,7 @@
- Fix crash for multibyte characters in file path, see issue #3230 and PR #3245 (@HSM95) - Fix crash for multibyte characters in file path, see issue #3230 and PR #3245 (@HSM95)
- Add missing mappings for various bash/zsh files, see PR #3262 (@AdamGaskins) - Add missing mappings for various bash/zsh files, see PR #3262 (@AdamGaskins)
- Send all bat errors to stderr by default, see #3336 (@JerryImMouse) - Send all bat errors to stderr by default, see #3336 (@JerryImMouse)
- Make --map-syntax target case insensitive to match --language, see #3206 (@keith-hall)
## Other ## Other
@@ -26,6 +27,8 @@
- Build script: replace string-based codegen with quote-based codegen #3340 (@cyqsimon) - Build script: replace string-based codegen with quote-based codegen #3340 (@cyqsimon)
- Improve code coverage of `--list-languages` parameter #2942 (@sblondon) - Improve code coverage of `--list-languages` parameter #2942 (@sblondon)
- Only start offload worker thread when there's more than 1 core #2956 (@cyqsimon) - Only start offload worker thread when there's more than 1 core #2956 (@cyqsimon)
- Update terminal-colorsaurus (the library used for dark/light detection) to 1.0, see #3347 (@bash)
- Update console dependency to 0.16, see #3351 (@musicinmybrain)
## Syntaxes ## Syntaxes
@@ -45,11 +48,14 @@
- Add syntax highlighting for VHDL, see #3337 (@JerryImMouse) - Add syntax highlighting for VHDL, see #3337 (@JerryImMouse)
- Add syntax mapping for certbot certificate configuration #3338 (@cyqsimon) - Add syntax mapping for certbot certificate configuration #3338 (@cyqsimon)
- Update Lean syntax from Lean 3 to Lean 4 #3322 (@YDX-2147483647) - Update Lean syntax from Lean 3 to Lean 4 #3322 (@YDX-2147483647)
- Map `.flatpakref` and `.flatpakrepo` files to INI syntax #3353 (@Ferenc-)
- Update hosts syntax #3368 (@keith-hall)
## Themes ## Themes
- Add Catppuccin, see #3317 (@SchweGELBin) - Add Catppuccin, see #3317 (@SchweGELBin)
- Updated Catppuccin, see #3333 (@SchweGELBin) - Updated Catppuccin, see #3333 (@SchweGELBin)
- Updated gruvbox, see #3372 (@Nicholas42)
## `bat` as a library ## `bat` as a library

128
Cargo.lock generated
View File

@@ -304,15 +304,15 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]] [[package]]
name = "console" name = "console"
version = "0.15.10" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" checksum = "2e09ced7ebbccb63b4c65413d821f2e00ce54c5ca4514ddc6b3c892fdbcbc69d"
dependencies = [ dependencies = [
"encode_unicode", "encode_unicode",
"libc", "libc",
"once_cell", "once_cell",
"unicode-width", "unicode-width",
"windows-sys 0.59.0", "windows-sys 0.60.2",
] ]
[[package]] [[package]]
@@ -613,7 +613,7 @@ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"wasi 0.13.3+wasi-0.2.2", "wasi 0.13.3+wasi-0.2.2",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1093,7 +1093,7 @@ dependencies = [
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1536,9 +1536,9 @@ dependencies = [
[[package]] [[package]]
name = "terminal-colorsaurus" name = "terminal-colorsaurus"
version = "0.4.7" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "858625398bdd5da7a96e8ad33a10031a50c3a5ad50d5aaa81a2827369a9c216c" checksum = "3f7226dad4b1817567c1e2f5d453897ef36abe79def7783af3fa241a694e30b3"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@@ -1546,13 +1546,14 @@ dependencies = [
"mio", "mio",
"terminal-trx", "terminal-trx",
"windows-sys 0.59.0", "windows-sys 0.59.0",
"xterm-color",
] ]
[[package]] [[package]]
name = "terminal-trx" name = "terminal-trx"
version = "0.2.3" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a5b836e7f4f81afe61b5cd399eee774f25edcfd47009a76e29f53bb6487833" checksum = "975b4233aefa1b02456d5e53b22c61653c743e308c51cf4181191d8ce41753ab"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@@ -1841,7 +1842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132"
dependencies = [ dependencies = [
"windows-core 0.56.0", "windows-core 0.56.0",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1851,7 +1852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143"
dependencies = [ dependencies = [
"windows-core 0.57.0", "windows-core 0.57.0",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1863,7 +1864,7 @@ dependencies = [
"windows-implement 0.56.0", "windows-implement 0.56.0",
"windows-interface 0.56.0", "windows-interface 0.56.0",
"windows-result", "windows-result",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1875,7 +1876,7 @@ dependencies = [
"windows-implement 0.57.0", "windows-implement 0.57.0",
"windows-interface 0.57.0", "windows-interface 0.57.0",
"windows-result", "windows-result",
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1928,7 +1929,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1937,7 +1938,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.52.6",
] ]
[[package]] [[package]]
@@ -1946,7 +1947,16 @@ version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [
"windows-targets 0.53.2",
] ]
[[package]] [[package]]
@@ -1955,14 +1965,30 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc", "windows_aarch64_msvc 0.52.6",
"windows_i686_gnu", "windows_i686_gnu 0.52.6",
"windows_i686_gnullvm", "windows_i686_gnullvm 0.52.6",
"windows_i686_msvc", "windows_i686_msvc 0.52.6",
"windows_x86_64_gnu", "windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc", "windows_x86_64_msvc 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.53.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef"
dependencies = [
"windows_aarch64_gnullvm 0.53.0",
"windows_aarch64_msvc 0.53.0",
"windows_i686_gnu 0.53.0",
"windows_i686_gnullvm 0.53.0",
"windows_i686_msvc 0.53.0",
"windows_x86_64_gnu 0.53.0",
"windows_x86_64_gnullvm 0.53.0",
"windows_x86_64_msvc 0.53.0",
] ]
[[package]] [[package]]
@@ -1971,48 +1997,96 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_aarch64_msvc"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnu"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3"
[[package]] [[package]]
name = "windows_i686_gnullvm" name = "windows_i686_gnullvm"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_gnullvm"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_i686_msvc"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnu"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.52.6" version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "windows_x86_64_msvc"
version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.7.11" version = "0.7.11"
@@ -2040,6 +2114,12 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "xterm-color"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4de5f056fb9dc8b7908754867544e26145767187aaac5a98495e88ad7cb8a80f"
[[package]] [[package]]
name = "yaml-rust" name = "yaml-rust"
version = "0.4.5" version = "0.4.5"

View File

@@ -45,7 +45,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
nu-ansi-term = "0.50.0" nu-ansi-term = "0.50.0"
ansi_colours = "^1.2" ansi_colours = "^1.2"
bincode = "1.0" bincode = "1.0"
console = "0.15.10" console = "0.16.0"
flate2 = "1.1" flate2 = "1.1"
once_cell = "1.20" once_cell = "1.20"
thiserror = "2.0" thiserror = "2.0"
@@ -68,7 +68,7 @@ walkdir = { version = "2.5", optional = true }
bytesize = { version = "1.3.0" } bytesize = { version = "1.3.0" }
encoding_rs = "0.8.35" encoding_rs = "0.8.35"
execute = { version = "0.2.13", optional = true } execute = { version = "0.2.13", optional = true }
terminal-colorsaurus = "0.4" terminal-colorsaurus = "1.0"
unicode-segmentation = "1.12.0" unicode-segmentation = "1.12.0"
itertools = "0.13.0" itertools = "0.13.0"

View File

@@ -178,7 +178,7 @@ You can combine `bat` with `git diff` to view lines around code changes with pro
highlighting: highlighting:
```bash ```bash
batdiff() { batdiff() {
git diff --name-only --relative --diff-filter=d -z | xargs --null bat --diff git diff --name-only --relative --diff-filter=d -z | xargs -0 bat --diff
} }
``` ```
If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras). If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras).
@@ -201,7 +201,7 @@ bat main.cpp | xclip
`MANPAGER` environment variable: `MANPAGER` environment variable:
```bash ```bash
export MANPAGER="sh -c 'sed -u -e \"s/\\x1B\[[0-9;]*m//g; s/.\\x08//g\" | bat -p -lman'" export MANPAGER="sh -c 'awk '\''{ gsub(/\x1B\[[0-9;]*m/, \"\", \$0); gsub(/.\x08/, \"\", \$0); print }'\'' | bat -p -lman'"
man 2 select man 2 select
``` ```
(replace `bat` with `batcat` if you are on Debian or Ubuntu) (replace `bat` with `batcat` if you are on Debian or Ubuntu)

View File

@@ -5,6 +5,24 @@ using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -ScriptBlock { Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition) param($wordToComplete, $commandAst, $cursorPosition)
$ArrayStyle = @('default', 'auto', 'full', 'plain', 'changes', 'header', 'header-filename', 'header-filesize', 'grid', 'rule', 'numbers', 'snip')
$ArrayCompletion = @('bash', 'fish', 'zsh', 'ps1')
$ArrayWhen = @('auto', 'never', 'always')
$ArrayYesNo = @('never', 'always')
$ArrayWrap = @('always', 'never', 'character')
$ArrayBinary = @('no-printing', 'as-text')
$ArrayPrint = @('unicode', 'caret')
function Get-MyThemes(){
$themes = {{PROJECT_EXECUTABLE}} --list-themes | ForEach-Object {$_ -replace "^(.*)$", '''$1'''} | select-object
return $themes
}
function Get-MyLanguages(){
$themes = {{PROJECT_EXECUTABLE}} --list-languages | ForEach-Object{[pscustomobject]@{MyParameter=$_.Substring(0,$_.IndexOf(":")).Trim();MyDescription=$_.Substring($_.IndexOf(":")+1)}} | select-object
return $themes
}
$commandElements = $commandAst.CommandElements $commandElements = $commandAst.CommandElements
$command = @( $command = @(
'{{PROJECT_EXECUTABLE}}' '{{PROJECT_EXECUTABLE}}'
@@ -12,86 +30,167 @@ Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -Script
$element = $commandElements[$i] $element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or if ($element -isnot [StringConstantExpressionAst] -or
$element.StringConstantType -ne [StringConstantType]::BareWord -or $element.StringConstantType -ne [StringConstantType]::BareWord -or
$element.Value.StartsWith('-')) { #$element.Value.StartsWith('-') -or
$element.Value -eq $wordToComplete) {
break break
} }
$element.Value $element.Value
}) -join ';' }) -join ';'
$completions = @(switch ($command) { $completions = @(switch -Wildcard ($command) {
'{{PROJECT_EXECUTABLE}}' { '*;--help' {
[CompletionResult]::new('-l', 'l', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.') break
[CompletionResult]::new('--language', 'language', [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.') }
[CompletionResult]::new('-H', 'H', [CompletionResultType]::ParameterName, 'Highlight lines N through M.') '*;--version' {
[CompletionResult]::new('--highlight-line', 'highlight-line', [CompletionResultType]::ParameterName, 'Highlight lines N through M.') break
[CompletionResult]::new('--file-name', 'file-name', [CompletionResultType]::ParameterName, 'Specify the name to display for a file.') }
[CompletionResult]::new('--diff-context', 'diff-context', [CompletionResultType]::ParameterName, 'diff-context') '*;--acknowledgements' {
[CompletionResult]::new('--tabs', 'tabs', [CompletionResultType]::ParameterName, 'Set the tab width to T spaces.') break
[CompletionResult]::new('--wrap', 'wrap', [CompletionResultType]::ParameterName, 'Specify the text-wrapping mode (*auto*, never, character).') }
[CompletionResult]::new('--terminal-width', 'terminal-width', [CompletionResultType]::ParameterName, 'Explicitly set the width of the terminal instead of determining it automatically. If prefixed with ''+'' or ''-'', the value will be treated as an offset to the actual terminal width. See also: ''--wrap''.') '*;--language' {
[CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'When to use colors (*auto*, never, always).') Get-MyLanguages |
[CompletionResult]::new('--italic-text', 'italic-text', [CompletionResultType]::ParameterName, 'Use italics in output (always, *never*)') ForEach-Object {[CompletionResult]::new(($_.MyParameter -replace "^(.*)$", '''$1'''), $_.MyParameter, [CompletionResultType]::ParameterName, $_.MyDescription ?? '_no value_')}
[CompletionResult]::new('--decorations', 'decorations', [CompletionResultType]::ParameterName, 'When to show the decorations (*auto*, never, always).') break
[CompletionResult]::new('--paging', 'paging', [CompletionResultType]::ParameterName, 'Specify when to use the pager, or use `-P` to disable (*auto*, never, always).') }
[CompletionResult]::new('--pager', 'pager', [CompletionResultType]::ParameterName, 'Determine which pager to use.') '*;--theme' {
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').') Get-MyThemes |
[CompletionResult]::new('--map-syntax', 'map-syntax', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterName, $_)}
[CompletionResult]::new('--theme', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.') break
[CompletionResult]::new('--theme-dark', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting for dark backgrounds.') }
[CompletionResult]::new('--theme-light', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting for light backgrounds.') '*;--binary' {
[CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*default*, auto, full, plain, changes, header, header-filename, header-filesize, grid, rule, numbers, snip).') $ArrayBinary |
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--line-range', 'line-range', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.') break
[CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).') }
[CompletionResult]::new('--show-all', 'show-all', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).') '*;--style' {
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').') $ArrayStyle |
[CompletionResult]::new('--plain', 'plain', [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('-d', 'd', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.') break
[CompletionResult]::new('--diff', 'diff', [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.') }
[CompletionResult]::new('-n', 'n', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').') '*;--wrap' {
[CompletionResult]::new('--number', 'number', [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').') $ArrayWrap |
[CompletionResult]::new('-f', 'f', [CompletionResultType]::ParameterName, 'f') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--force-colorization', 'force-colorization', [CompletionResultType]::ParameterName, 'force-colorization') break
[CompletionResult]::new('-P', 'P', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''') }
[CompletionResult]::new('--no-paging', 'no-paging', [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''') '*;--color' {
[CompletionResult]::new('--list-themes', 'list-themes', [CompletionResultType]::ParameterName, 'Display all supported highlighting themes.') $ArrayWhen |
[CompletionResult]::new('-L', 'L', [CompletionResultType]::ParameterName, 'Display all supported languages.') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--list-languages', 'list-languages', [CompletionResultType]::ParameterName, 'Display all supported languages.') break
[CompletionResult]::new('-u', 'u', [CompletionResultType]::ParameterName, 'u') }
[CompletionResult]::new('--unbuffered', 'unbuffered', [CompletionResultType]::ParameterName, 'unbuffered') '*;--italic-text' {
[CompletionResult]::new('--no-config', 'no-config', [CompletionResultType]::ParameterName, 'Do not use the configuration file') $ArrayYesNo |
[CompletionResult]::new('--no-custom-assets', 'no-custom-assets', [CompletionResultType]::ParameterName, 'Do not load custom assets') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--lessopen', 'lessopen', [CompletionResultType]::ParameterName, 'Enable the $LESSOPEN preprocessor') break
[CompletionResult]::new('--no-lessopen', 'no-lessopen', [CompletionResultType]::ParameterName, 'Disable the $LESSOPEN preprocessor if enabled (overrides --lessopen)') }
[CompletionResult]::new('--config-file', 'config-file', [CompletionResultType]::ParameterName, 'Show path to the configuration file.') '*;--paging' {
[CompletionResult]::new('--generate-config-file', 'generate-config-file', [CompletionResultType]::ParameterName, 'Generates a default configuration file.') $ArrayWhen |
[CompletionResult]::new('--config-dir', 'config-dir', [CompletionResultType]::ParameterName, 'Show bat''s configuration directory.') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--cache-dir', 'cache-dir', [CompletionResultType]::ParameterName, 'Show bat''s cache directory.') break
[CompletionResult]::new('--diagnostic', 'diagnostic', [CompletionResultType]::ParameterName, 'Show diagnostic information for bug reports.') }
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print this help message.') '*;--decorations' {
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print this help message.') $ArrayWhen |
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Show version information.') ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Show version information.') break
## Completion of the 'cache' command itself is removed for better UX }
## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802 '*;--completion' {
$ArrayCompletion |
ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
break
}
'*;--strip-ansi' {
$ArrayWhen |
ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
break
}
'*;--nonprintable-notation' {
$ArrayPrint |
ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)}
break
}
'*;--generate-config-file' {
break break
} }
'{{PROJECT_EXECUTABLE}};cache' { '{{PROJECT_EXECUTABLE}};cache' {
[CompletionResult]::new('--source', 'source', [CompletionResultType]::ParameterName, 'Use a different directory to load syntaxes and themes from.') [CompletionResult]::new('--source' , 'source' , [CompletionResultType]::ParameterName, 'Use a different directory to load syntaxes and themes from.')
[CompletionResult]::new('--target', 'target', [CompletionResultType]::ParameterName, 'Use a different directory to store the cached syntax and theme set.') [CompletionResult]::new('--target' , 'target' , [CompletionResultType]::ParameterName, 'Use a different directory to store the cached syntax and theme set.')
[CompletionResult]::new('-b', 'b', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.') # [CompletionResult]::new('-b' , 'b' , [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
[CompletionResult]::new('--build', 'build', [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.') [CompletionResult]::new('--build' , 'build' , [CompletionResultType]::ParameterName, 'Initialize (or update) the syntax/theme cache.')
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.') # [CompletionResult]::new('-c' , 'c' , [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
[CompletionResult]::new('--clear', 'clear', [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.') [CompletionResult]::new('--clear' , 'clear' , [CompletionResultType]::ParameterName, 'Remove the cached syntax definitions and themes.')
[CompletionResult]::new('--blank', 'blank', [CompletionResultType]::ParameterName, 'Create completely new syntax and theme sets (instead of appending to the default sets).') [CompletionResult]::new('--blank' , 'blank' , [CompletionResultType]::ParameterName, 'Create completely new syntax and theme sets (instead of appending to the default sets).')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information') # [CompletionResult]::new('-h' , 'h' , [CompletionResultType]::ParameterName, 'Prints help information')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information') [CompletionResult]::new('--help' , 'help' , [CompletionResultType]::ParameterName, 'Prints help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information') # [CompletionResult]::new('-V' , 'V' , [CompletionResultType]::ParameterName, 'Prints version information')
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information') # [CompletionResult]::new('--version' , 'version' , [CompletionResultType]::ParameterName, 'Prints version information')
break
}
default {
# [CompletionResult]::new('-l' , 'l' , [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
[CompletionResult]::new('--language' , 'language' , [CompletionResultType]::ParameterName, 'Set the language for syntax highlighting.')
# [CompletionResult]::new('-H' , 'H' , [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
[CompletionResult]::new('--highlight-line' , 'highlight-line' , [CompletionResultType]::ParameterName, 'Highlight lines N through M.')
[CompletionResult]::new('--file-name' , 'file-name' , [CompletionResultType]::ParameterName, 'Specify the name to display for a file.')
[CompletionResult]::new('--diff-context' , 'diff-context' , [CompletionResultType]::ParameterName, 'diff-context')
[CompletionResult]::new('--tabs' , 'tabs' , [CompletionResultType]::ParameterName, 'Set the tab width to T spaces.')
[CompletionResult]::new('--wrap' , 'wrap' , [CompletionResultType]::ParameterName, 'Specify the text-wrapping mode (*auto*, character).')
[CompletionResult]::new('--terminal-width' , 'terminal-width' , [CompletionResultType]::ParameterName, 'Explicitly set the width of the terminal instead of determining it automatically. If prefixed with ''+'' or ''-'', the value will be treated as an offset to the actual terminal width. See also: ''--wrap''.')
[CompletionResult]::new('--color' , 'color' , [CompletionResultType]::ParameterName, 'When to use colors (*auto*, never, always).')
[CompletionResult]::new('--italic-text' , 'italic-text' , [CompletionResultType]::ParameterName, 'Use italics in output (always, *never*)')
[CompletionResult]::new('--decorations' , 'decorations' , [CompletionResultType]::ParameterName, 'When to show the decorations (*auto*, never, always).')
[CompletionResult]::new('--paging' , 'paging' , [CompletionResultType]::ParameterName, 'Specify when to use the pager, or use ''-P'' to disable (*auto*, never, always).')
[CompletionResult]::new('--pager' , 'pager' , [CompletionResultType]::ParameterName, 'Determine which pager to use.')
# [CompletionResult]::new('-m' , 'm' , [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
[CompletionResult]::new('--map-syntax' , 'map-syntax' , [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
[CompletionResult]::new('--theme' , 'theme' , [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.')
[CompletionResult]::new('--theme-dark' , 'themedark' , [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting for dark backgrounds.')
[CompletionResult]::new('--theme-light' , 'themelight' , [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting for light backgrounds.')
[CompletionResult]::new('--style' , 'style' , [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*default*, auto, full, plain, changes, header, header-filename, header-filesize, grid, rule, numbers, snip).')
# [CompletionResult]::new('-r' , 'r' , [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
[CompletionResult]::new('--line-range' , 'line-range' , [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
# [CompletionResult]::new('-A' , 'A' , [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
[CompletionResult]::new('--show-all' , 'show-all' , [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
[CompletionResult]::new('--nonprintable-notation' , 'nonprintable-notation' , [CompletionResultType]::ParameterName, 'Set notation for non-printable characters. (unicode, caret)')
[CompletionResult]::new('--chop-long-lines' , 'chop-long-lines' , [CompletionResultType]::ParameterName, 'Truncate all lines longer than screen width. Alias for ''--wrap=never''.')
[CompletionResult]::new('--binary' , 'binary' , [CompletionResultType]::ParameterName, 'How to treat binary content. (*no-printing*, as-text)')
[CompletionResult]::new('--ignored-suffix' , 'ignored-suffix' , [CompletionResultType]::ParameterName, 'Ignore extension. For example: ''bat --ignored-suffix ".dev" my_file.json.dev'' will use JSON syntax, and ignore ''.dev''')
[CompletionResult]::new('--squeeze-blank' , 'squeeze-blank' , [CompletionResultType]::ParameterName, 'Squeeze consecutive empty lines into a single empty line.')
[CompletionResult]::new('--squeeze-limit' , 'squeeze-limit' , [CompletionResultType]::ParameterName, 'Set the maximum number of consecutive empty lines to be printed.')
[CompletionResult]::new('--strip-ansi' , 'strip-ansi' , [CompletionResultType]::ParameterName, 'Specify when to strip ANSI escape sequences from the input. The automatic mode will remove escape sequences unless the syntax highlighting language is plain text. (auto, always, *never*).')
# [CompletionResult]::new('-p' , 'p' , [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
[CompletionResult]::new('--plain' , 'plain' , [CompletionResultType]::ParameterName, 'Show plain style (alias for ''--style=plain'').')
# [CompletionResult]::new('-d' , 'd' , [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
[CompletionResult]::new('--diff' , 'diff' , [CompletionResultType]::ParameterName, 'Only show lines that have been added/removed/modified.')
# [CompletionResult]::new('-n' , 'n' , [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
[CompletionResult]::new('--number' , 'number' , [CompletionResultType]::ParameterName, 'Show line numbers (alias for ''--style=numbers'').')
# [CompletionResult]::new('-f' , 'f' , [CompletionResultType]::ParameterName, 'f')
[CompletionResult]::new('--force-colorization' , 'force-colorization' , [CompletionResultType]::ParameterName, 'force-colorization')
# [CompletionResult]::new('-P' , 'P' , [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
[CompletionResult]::new('--no-paging' , 'no-paging' , [CompletionResultType]::ParameterName, 'Alias for ''--paging=never''')
[CompletionResult]::new('--list-themes' , 'list-themes' , [CompletionResultType]::ParameterName, 'Display all supported highlighting themes.')
# [CompletionResult]::new('-L' , 'L' , [CompletionResultType]::ParameterName, 'Display all supported languages.')
[CompletionResult]::new('--list-languages' , 'list-languages' , [CompletionResultType]::ParameterName, 'Display all supported languages.')
# [CompletionResult]::new('-u' , 'u' , [CompletionResultType]::ParameterName, 'u')
[CompletionResult]::new('--unbuffered' , 'unbuffered' , [CompletionResultType]::ParameterName, 'unbuffered')
[CompletionResult]::new('--completion' , 'completion' , [CompletionResultType]::ParameterName, 'Show shell completion for a certain shell. [possible values: bash, fish, zsh, ps1]')
[CompletionResult]::new('--no-config' , 'no-config' , [CompletionResultType]::ParameterName, 'Do not use the configuration file')
[CompletionResult]::new('--no-custom-assets' , 'no-custom-assets' , [CompletionResultType]::ParameterName, 'Do not load custom assets')
[CompletionResult]::new('--lessopen' , 'lessopen' , [CompletionResultType]::ParameterName, 'Enable the $LESSOPEN preprocessor')
[CompletionResult]::new('--no-lessopen' , 'no-lessopen' , [CompletionResultType]::ParameterName, 'Disable the $LESSOPEN preprocessor if enabled (overrides --lessopen)')
[CompletionResult]::new('--config-file' , 'config-file' , [CompletionResultType]::ParameterName, 'Show path to the configuration file.')
[CompletionResult]::new('--generate-config-file' , 'generate-config-file' , [CompletionResultType]::ParameterName, 'Generates a default configuration file.')
[CompletionResult]::new('--config-dir' , 'config-dir' , [CompletionResultType]::ParameterName, 'Show bat''s configuration directory.')
[CompletionResult]::new('--cache-dir' , 'cache-dir' , [CompletionResultType]::ParameterName, 'Show bat''s cache directory.')
[CompletionResult]::new('--acknowledgements' , 'acknowledgements' , [CompletionResultType]::ParameterName, 'Show acknowledgements.')
[CompletionResult]::new('--set-terminal-title' , 'set-terminal-title' , [CompletionResultType]::ParameterName, 'Sets terminal title to filenames when using a pager.')
[CompletionResult]::new('--diagnostic' , 'diagnostic' , [CompletionResultType]::ParameterName, 'Show diagnostic information for bug reports.')
# [CompletionResult]::new('-h' , 'h' , [CompletionResultType]::ParameterName, 'Print this help message.')
[CompletionResult]::new('--help' , 'help' , [CompletionResultType]::ParameterName, 'Print this help message.')
# [CompletionResult]::new('-V' , 'V' , [CompletionResultType]::ParameterName, 'Show version information.')
[CompletionResult]::new('--version' , 'version' , [CompletionResultType]::ParameterName, 'Show version information.')
break break
} }
}) })
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } | $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText Sort-Object -Property CompletionText
} }

View File

@@ -37,6 +37,23 @@ Use character sequences like ^G, ^J, ^@, .. to identify non-printable characters
Use special Unicode code points to identify non-printable characters Use special Unicode code points to identify non-printable characters
.RE .RE
.HP .HP
\fB\-\-binary\fR <behavior>
.IP
How to treat binary content.
Possible values:
.RS
.IP "no\-printing"
Do not print any binary content (default)
.IP "as\-text"
Treat binary content as normal text
.RE
.HP
\fB\-\-completion\fR <SHELL>
.IP
Show shell completion for a certain shell.
Possible values: bash, fish, zsh, ps1
.HP
\fB\-p\fR, \fB\-\-plain\fR \fB\-p\fR, \fB\-\-plain\fR
.IP .IP
Only show plain style, no decorations. This is an alias for Only show plain style, no decorations. This is an alias for
@@ -197,6 +214,12 @@ Squeeze consecutive empty lines into a single empty line.
.IP .IP
Set the maximum number of consecutive empty lines to be printed. Set the maximum number of consecutive empty lines to be printed.
.HP .HP
\fB\-\-strip\-ansi\fR <when>
.IP
Specify when to strip ANSI escape sequences from the input. The automatic mode will remove
escape sequences unless the syntax highlighting language is plain text. Possible values:
auto, always, *never*.
.HP
\fB\-\-style\fR <style\-components> \fB\-\-style\fR <style\-components>
.IP .IP
Configure which elements (line numbers, file headers, grid borders, Git modifications, Configure which elements (line numbers, file headers, grid borders, Git modifications,

View File

@@ -1,5 +1,6 @@
%YAML 1.2 %YAML 1.2
--- ---
name: x86_64 Assembly
file_extensions: [yasm, nasm, asm, inc, mac] file_extensions: [yasm, nasm, asm, inc, mac]
scope: source.asm.x86_64 scope: source.asm.x86_64
@@ -1364,4 +1365,3 @@ contexts:
scope: invalid.keyword.operator.word.mnemonic.sse5.packed-arithmetic scope: invalid.keyword.operator.word.mnemonic.sse5.packed-arithmetic
- match: '(?i)\b(pcmov|permp[ds]|pperm|prot[bdqw]|psh[al][bdqw])\b' - match: '(?i)\b(pcmov|permp[ds]|pperm|prot[bdqw]|psh[al][bdqw])\b'
scope: invalid.keyword.operator.word.mnemonic.sse5.simd-integer scope: invalid.keyword.operator.word.mnemonic.sse5.simd-integer
...

View File

@@ -1,23 +0,0 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: hosts
file_extensions:
- hosts
scope: source.hosts
contexts:
main:
- scope: comment.line.number-sign
match: \#.*
comment: comment
- match: ^\s*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[0-9a-f:]+)
comment: ipaddress
scope: constant.numeric.ipaddress
- match: \s(localhost|ip6-loopback|ip6-localhost|ip6-localnet|ip6-mcastprefix|ip6-allnodes|ip6-allrouters|ip6-allhosts|broadcasthost)\b
scope: keyword.host.predefined}
comment: prefdfined

View File

@@ -163,7 +163,7 @@ git show v0.6.0:src/main.rs | bat -l rs
볼 수 있습니다: 볼 수 있습니다:
```bash ```bash
batdiff() { batdiff() {
git diff --name-only --diff-filter=d -z | xargs --null bat --diff git diff --name-only --relative --diff-filter=d -z | xargs -0 bat --diff
} }
``` ```
이것을 별도의 도구로 쓰고 싶다면 이것을 별도의 도구로 쓰고 싶다면

View File

@@ -145,7 +145,7 @@ git show v0.6.0:src/main.rs | bat -l rs
Вы можете использовать `bat` с `git diff` для просмотра строк кода вокруг изменений с подсветкой синтаксиса: Вы можете использовать `bat` с `git diff` для просмотра строк кода вокруг изменений с подсветкой синтаксиса:
```bash ```bash
batdiff() { batdiff() {
git diff --name-only --relative --diff-filter=d | xargs bat --diff git diff --name-only --relative --diff-filter=d -z | xargs -0 bat --diff
} }
``` ```
Если вы хотите использовать это как отдельную программу, посмотрите `batdiff` из [`bat-extras`](https://github.com/eth-p/bat-extras). Если вы хотите использовать это как отдельную программу, посмотрите `batdiff` из [`bat-extras`](https://github.com/eth-p/bat-extras).

View File

@@ -150,7 +150,7 @@ git show v0.6.0:src/main.rs | bat -l rs
```bash ```bash
batdiff() { batdiff() {
git diff --name-only --diff-filter=d -z | xargs --null bat --diff git diff --name-only --relative --diff-filter=d -z | xargs -0 bat --diff
} }
``` ```
@@ -170,20 +170,23 @@ bat main.cpp | xclip
#### `man` #### `man`
`bat`也能给`man`的输出上色。这需要设置`MANPAGER`环境变量: `bat` 可以通过设置 `MANPAGER` 环境变量,用作 `man` 的彩色分页器
```bash ```bash
export MANPAGER="sh -c 'col -bx | bat -l man -p'" export MANPAGER="sh -c 'awk '\''{ gsub(/\x1B\[[0-9;]*m/, \"\", \$0); gsub(/.\x08/, \"\", \$0); print }'\'' | bat -p -lman'"
man 2 select man 2 select
``` ```
(如果你使用的是 Debian 或 Ubuntu使用`batcat`替换`bat` (如果你使用 Debian 或 Ubuntu请将 `batcat` 替换`bat`
如果你遇到格式化问题,设置`MANROFFOPT="-c"`也许会有帮助 如果你希望将其打包为一个新的命令,也可以使用 [`batman`](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md)
`batman`能提供类似功能——作为一个独立的命令。 > [!WARNING]
> 在使用 Mandoc 的 `man` 实现时,这[无法](https://github.com/sharkdp/bat/issues/1145)直接工作。
>
> 请使用 `batman`,或将此 Shell 脚本包装为 [Shebang 可执行文件](https://en.wikipedia.org/wiki/Shebang_(Unix)),并将 `MANPAGER` 指向该文件。
注意[man page 语法](assets/syntaxes/02_Extra/Manpage.sublime-syntax) 还需要完善。在使用特定的`man`实现时该功能[无法正常工作](https://github.com/sharkdp/bat/issues/1145) 注意[Manpage 语法](assets/syntaxes/02_Extra/Manpage.sublime-syntax)是在此仓库中开发的,仍需一些改进
#### `prettier` / `shfmt` / `rustfmt` #### `prettier` / `shfmt` / `rustfmt`

View File

@@ -163,7 +163,7 @@ impl HighlightingAssets {
if let Some(MappingTarget::MapTo(syntax_name)) = syntax_match { if let Some(MappingTarget::MapTo(syntax_name)) = syntax_match {
return self return self
.find_syntax_by_name(syntax_name)? .find_syntax_by_token(syntax_name)?
.ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned())); .ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned()));
} }
@@ -259,6 +259,13 @@ impl HighlightingAssets {
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })) .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
} }
fn find_syntax_by_token(&self, token: &str) -> Result<Option<SyntaxReferenceInSet>> {
let syntax_set = self.get_syntax_set()?;
Ok(syntax_set
.find_syntax_by_token(token)
.map(|syntax| SyntaxReferenceInSet { syntax, syntax_set }))
}
fn get_syntax_for_file_name( fn get_syntax_for_file_name(
&self, &self,
file_name: &OsStr, file_name: &OsStr,

View File

@@ -0,0 +1,5 @@
[mappings]
"INI" = [
"*.flatpakref",
"*.flatpakrepo"
]

View File

@@ -266,10 +266,10 @@ impl ColorSchemeDetector for TerminalColorSchemeDetector {
} }
fn detect(&self) -> Option<ColorScheme> { fn detect(&self) -> Option<ColorScheme> {
use terminal_colorsaurus::{color_scheme, ColorScheme as ColorsaurusScheme, QueryOptions}; use terminal_colorsaurus::{theme_mode, QueryOptions, ThemeMode};
match color_scheme(QueryOptions::default()).ok()? { match theme_mode(QueryOptions::default()).ok()? {
ColorsaurusScheme::Dark => Some(ColorScheme::Dark), ThemeMode::Dark => Some(ColorScheme::Dark),
ColorsaurusScheme::Light => Some(ColorScheme::Light), ThemeMode::Light => Some(ColorScheme::Light),
} }
} }
} }

View File

@@ -2821,6 +2821,27 @@ fn highlighting_independant_from_map_syntax_case() {
.stderr(""); .stderr("");
} }
#[test]
fn map_syntax_target_syntax_case_insensitive() {
let expected = bat()
.arg("-f")
.arg("--map-syntax=*.config:json")
.arg("map-syntax_case.Config")
.assert()
.get_output()
.stdout
.clone();
bat()
.arg("-f")
.arg("--map-syntax=*.config:json")
.arg("map-syntax_case.Config")
.assert()
.success()
.stdout(expected)
.stderr("");
}
#[test] #[test]
fn strip_ansi_always_strips_ansi() { fn strip_ansi_always_strips_ansi() {
bat() bat()

View File

@@ -1,8 +1,8 @@
#this is a comment in the hosts file #this is a comment in the hosts file
127.0.0.1  localhost 127.0.0.1 localhost
192.168.0.1 sample.test #a comment 192.168.0.1 sample.test #a comment
192.160.0.200 try.sample.test try #another comment 192.160.0.200 try.sample.test try #another comment
216.58.223.238 google.com 216.58.223.238 google.com
::1 localhost.try ip6-localhost ::1 localhost.try ip6-localhost