diff --git a/.github/workflows/Auto-merge-dependabot-PRs.yml b/.github/workflows/Auto-merge-dependabot-PRs.yml deleted file mode 100644 index 741eb684..00000000 --- a/.github/workflows/Auto-merge-dependabot-PRs.yml +++ /dev/null @@ -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 }} diff --git a/.gitmodules b/.gitmodules index 1ba4495e..860bcbb0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -113,9 +113,6 @@ [submodule "assets/syntaxes/DotENV"] path = assets/syntaxes/02_Extra/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"] path = assets/syntaxes/02_Extra/ssh-config url = https://github.com/robballou/sublimetext-sshconfig.git @@ -177,7 +174,7 @@ url = https://github.com/euler0/sublime-glsl [submodule "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"] path = assets/syntaxes/02_Extra/Apache url = https://github.com/colinta/ApacheConf.tmLanguage @@ -278,3 +275,6 @@ [submodule "assets/syntaxes/02_Extra/SmartVHDL"] path = assets/syntaxes/02_Extra/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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 43abf5b4..5ec95a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - 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) - 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 @@ -26,6 +27,8 @@ - Build script: replace string-based codegen with quote-based codegen #3340 (@cyqsimon) - Improve code coverage of `--list-languages` parameter #2942 (@sblondon) - 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 @@ -45,11 +48,14 @@ - Add syntax highlighting for VHDL, see #3337 (@JerryImMouse) - Add syntax mapping for certbot certificate configuration #3338 (@cyqsimon) - 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 - Add Catppuccin, see #3317 (@SchweGELBin) - Updated Catppuccin, see #3333 (@SchweGELBin) +- Updated gruvbox, see #3372 (@Nicholas42) ## `bat` as a library diff --git a/Cargo.lock b/Cargo.lock index 6cbcd425..59dbd349 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -304,15 +304,15 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "console" -version = "0.15.10" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" +checksum = "2e09ced7ebbccb63b4c65413d821f2e00ce54c5ca4514ddc6b3c892fdbcbc69d" dependencies = [ "encode_unicode", "libc", "once_cell", "unicode-width", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -613,7 +613,7 @@ dependencies = [ "cfg-if", "libc", "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1093,7 +1093,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1536,9 +1536,9 @@ dependencies = [ [[package]] name = "terminal-colorsaurus" -version = "0.4.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "858625398bdd5da7a96e8ad33a10031a50c3a5ad50d5aaa81a2827369a9c216c" +checksum = "3f7226dad4b1817567c1e2f5d453897ef36abe79def7783af3fa241a694e30b3" dependencies = [ "cfg-if", "libc", @@ -1546,13 +1546,14 @@ dependencies = [ "mio", "terminal-trx", "windows-sys 0.59.0", + "xterm-color", ] [[package]] name = "terminal-trx" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a5b836e7f4f81afe61b5cd399eee774f25edcfd47009a76e29f53bb6487833" +checksum = "975b4233aefa1b02456d5e53b22c61653c743e308c51cf4181191d8ce41753ab" dependencies = [ "cfg-if", "libc", @@ -1841,7 +1842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ "windows-core 0.56.0", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1851,7 +1852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ "windows-core 0.57.0", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1863,7 +1864,7 @@ dependencies = [ "windows-implement 0.56.0", "windows-interface 0.56.0", "windows-result", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1875,7 +1876,7 @@ dependencies = [ "windows-implement 0.57.0", "windows-interface 0.57.0", "windows-result", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1928,7 +1929,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1937,7 +1938,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1946,7 +1947,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 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]] @@ -1955,14 +1965,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "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]] @@ -1971,48 +1997,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "winnow" version = "0.7.11" @@ -2040,6 +2114,12 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "xterm-color" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4de5f056fb9dc8b7908754867544e26145767187aaac5a98495e88ad7cb8a80f" + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index bc5ff954..0b5187c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine nu-ansi-term = "0.50.0" ansi_colours = "^1.2" bincode = "1.0" -console = "0.15.10" +console = "0.16.0" flate2 = "1.1" once_cell = "1.20" thiserror = "2.0" @@ -68,7 +68,7 @@ walkdir = { version = "2.5", optional = true } bytesize = { version = "1.3.0" } encoding_rs = "0.8.35" execute = { version = "0.2.13", optional = true } -terminal-colorsaurus = "0.4" +terminal-colorsaurus = "1.0" unicode-segmentation = "1.12.0" itertools = "0.13.0" diff --git a/README.md b/README.md index 03809435..8bcd6d46 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ You can combine `bat` with `git diff` to view lines around code changes with pro highlighting: ```bash 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). @@ -201,7 +201,7 @@ bat main.cpp | xclip `MANPAGER` environment variable: ```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 ``` (replace `bat` with `batcat` if you are on Debian or Ubuntu) diff --git a/assets/completions/_bat.ps1.in b/assets/completions/_bat.ps1.in index b6f62aae..7061b9db 100644 --- a/assets/completions/_bat.ps1.in +++ b/assets/completions/_bat.ps1.in @@ -5,6 +5,24 @@ using namespace System.Management.Automation.Language Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -ScriptBlock { 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 $command = @( '{{PROJECT_EXECUTABLE}}' @@ -12,86 +30,167 @@ Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -Script $element = $commandElements[$i] if ($element -isnot [StringConstantExpressionAst] -or $element.StringConstantType -ne [StringConstantType]::BareWord -or - $element.Value.StartsWith('-')) { + #$element.Value.StartsWith('-') -or + $element.Value -eq $wordToComplete) { break } $element.Value }) -join ';' - $completions = @(switch ($command) { - '{{PROJECT_EXECUTABLE}}' { - [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*, 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''.') - [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', '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.') - [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('-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('--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('--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.') - ## Completion of the 'cache' command itself is removed for better UX - ## See https://github.com/sharkdp/bat/issues/2085#issuecomment-1271646802 + $completions = @(switch -Wildcard ($command) { + '*;--help' { + break + } + '*;--version' { + break + } + '*;--acknowledgements' { + break + } + '*;--language' { + Get-MyLanguages | + ForEach-Object {[CompletionResult]::new(($_.MyParameter -replace "^(.*)$", '''$1'''), $_.MyParameter, [CompletionResultType]::ParameterName, $_.MyDescription ?? '_no value_')} + break + } + '*;--theme' { + Get-MyThemes | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterName, $_)} + break + } + '*;--binary' { + $ArrayBinary | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--style' { + $ArrayStyle | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--wrap' { + $ArrayWrap | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--color' { + $ArrayWhen | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--italic-text' { + $ArrayYesNo | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--paging' { + $ArrayWhen | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--decorations' { + $ArrayWhen | + ForEach-Object {[System.Management.Automation.CompletionResult]::new($_, $_, [CompletionResultType]::ParameterValue, $_)} + break + } + '*;--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 } '{{PROJECT_EXECUTABLE}};cache' { - [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('-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('-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('--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('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information') - [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information') - [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints version information') + [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('-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('-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('--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('--help' , 'help' , [CompletionResultType]::ParameterName, 'Prints help information') + # [CompletionResult]::new('-V' , 'V' , [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 } }) $completions.Where{ $_.CompletionText -like "$wordToComplete*" } | - Sort-Object -Property ListItemText + Sort-Object -Property CompletionText } diff --git a/assets/manual/bat.1.in b/assets/manual/bat.1.in index 84608c15..86923db7 100644 --- a/assets/manual/bat.1.in +++ b/assets/manual/bat.1.in @@ -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 .RE .HP +\fB\-\-binary\fR +.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 +.IP +Show shell completion for a certain shell. +Possible values: bash, fish, zsh, ps1 +.HP \fB\-p\fR, \fB\-\-plain\fR .IP 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 Set the maximum number of consecutive empty lines to be printed. .HP +\fB\-\-strip\-ansi\fR +.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 .IP Configure which elements (line numbers, file headers, grid borders, Git modifications, diff --git a/assets/syntaxes/02_Extra/Assembly (x86_64).sublime-syntax b/assets/syntaxes/02_Extra/Assembly (x86_64).sublime-syntax index 1d91df82..6aa8150c 100644 --- a/assets/syntaxes/02_Extra/Assembly (x86_64).sublime-syntax +++ b/assets/syntaxes/02_Extra/Assembly (x86_64).sublime-syntax @@ -1,5 +1,6 @@ %YAML 1.2 --- +name: x86_64 Assembly file_extensions: [yasm, nasm, asm, inc, mac] scope: source.asm.x86_64 @@ -1364,4 +1365,3 @@ contexts: scope: invalid.keyword.operator.word.mnemonic.sse5.packed-arithmetic - match: '(?i)\b(pcmov|permp[ds]|pperm|prot[bdqw]|psh[al][bdqw])\b' scope: invalid.keyword.operator.word.mnemonic.sse5.simd-integer -... \ No newline at end of file diff --git a/assets/syntaxes/02_Extra/Hosts.sublime-syntax b/assets/syntaxes/02_Extra/Hosts.sublime-syntax deleted file mode 100644 index eac0ec0e..00000000 --- a/assets/syntaxes/02_Extra/Hosts.sublime-syntax +++ /dev/null @@ -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 - diff --git a/assets/syntaxes/02_Extra/hosts b/assets/syntaxes/02_Extra/hosts index 21250a71..60ed92c4 160000 --- a/assets/syntaxes/02_Extra/hosts +++ b/assets/syntaxes/02_Extra/hosts @@ -1 +1 @@ -Subproject commit 21250a7117655b0525821237b98b882dcc231350 +Subproject commit 60ed92c472dc6038a13a38d033bba6bc64fd6913 diff --git a/assets/syntaxes/02_Extra/typst-syntax-highlight b/assets/syntaxes/02_Extra/typst-syntax-highlight index 3f2561d4..4e2e68b0 160000 --- a/assets/syntaxes/02_Extra/typst-syntax-highlight +++ b/assets/syntaxes/02_Extra/typst-syntax-highlight @@ -1 +1 @@ -Subproject commit 3f2561d4d891f9f326fa70f9f06b6e99fda8adc3 +Subproject commit 4e2e68b0a13555720a5ff0c4b32db98ddf490ed1 diff --git a/assets/themes/gruvbox b/assets/themes/gruvbox index 64c47250..40503472 160000 --- a/assets/themes/gruvbox +++ b/assets/themes/gruvbox @@ -1 +1 @@ -Subproject commit 64c47250e54298b91e2cf8d401320009aba9f991 +Subproject commit 40503472826e51d87666e548a0634c4f1d74938c diff --git a/doc/README-ko.md b/doc/README-ko.md index 55cd8818..2b61abea 100644 --- a/doc/README-ko.md +++ b/doc/README-ko.md @@ -163,7 +163,7 @@ git show v0.6.0:src/main.rs | bat -l rs 볼 수 있습니다: ```bash 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 } ``` 이것을 별도의 도구로 쓰고 싶다면 diff --git a/doc/README-ru.md b/doc/README-ru.md index 06093077..06c9a4f4 100644 --- a/doc/README-ru.md +++ b/doc/README-ru.md @@ -145,7 +145,7 @@ git show v0.6.0:src/main.rs | bat -l rs Вы можете использовать `bat` с `git diff` для просмотра строк кода вокруг изменений с подсветкой синтаксиса: ```bash 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). diff --git a/doc/README-zh.md b/doc/README-zh.md index b626ca8e..586a4856 100644 --- a/doc/README-zh.md +++ b/doc/README-zh.md @@ -150,7 +150,7 @@ git show v0.6.0:src/main.rs | bat -l rs ```bash 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` -`bat`也能给`man`的输出上色。这需要设置`MANPAGER`环境变量: +`bat` 可以通过设置 `MANPAGER` 环境变量,用作 `man` 的彩色分页器: ```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 ``` -(如果你使用的是 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` diff --git a/src/assets.rs b/src/assets.rs index a5608e3b..ed6f27e9 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -163,7 +163,7 @@ impl HighlightingAssets { if let Some(MappingTarget::MapTo(syntax_name)) = syntax_match { return self - .find_syntax_by_name(syntax_name)? + .find_syntax_by_token(syntax_name)? .ok_or_else(|| Error::UnknownSyntax(syntax_name.to_owned())); } @@ -259,6 +259,13 @@ impl HighlightingAssets { .map(|syntax| SyntaxReferenceInSet { syntax, syntax_set })) } + fn find_syntax_by_token(&self, token: &str) -> Result> { + 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( &self, file_name: &OsStr, diff --git a/src/syntax_mapping/builtins/linux/50-flatpak.toml b/src/syntax_mapping/builtins/linux/50-flatpak.toml new file mode 100644 index 00000000..76cc70b1 --- /dev/null +++ b/src/syntax_mapping/builtins/linux/50-flatpak.toml @@ -0,0 +1,5 @@ +[mappings] +"INI" = [ + "*.flatpakref", + "*.flatpakrepo" +] diff --git a/src/theme.rs b/src/theme.rs index b2903b86..90c0e3dc 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -266,10 +266,10 @@ impl ColorSchemeDetector for TerminalColorSchemeDetector { } fn detect(&self) -> Option { - use terminal_colorsaurus::{color_scheme, ColorScheme as ColorsaurusScheme, QueryOptions}; - match color_scheme(QueryOptions::default()).ok()? { - ColorsaurusScheme::Dark => Some(ColorScheme::Dark), - ColorsaurusScheme::Light => Some(ColorScheme::Light), + use terminal_colorsaurus::{theme_mode, QueryOptions, ThemeMode}; + match theme_mode(QueryOptions::default()).ok()? { + ThemeMode::Dark => Some(ColorScheme::Dark), + ThemeMode::Light => Some(ColorScheme::Light), } } } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index c367c538..0f570f89 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -2821,6 +2821,27 @@ fn highlighting_independant_from_map_syntax_case() { .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] fn strip_ansi_always_strips_ansi() { bat() diff --git a/tests/syntax-tests/highlighted/Hosts/hosts b/tests/syntax-tests/highlighted/Hosts/hosts index 8d322f00..22166747 100644 --- a/tests/syntax-tests/highlighted/Hosts/hosts +++ b/tests/syntax-tests/highlighted/Hosts/hosts @@ -1,8 +1,8 @@ -#this is a comment in the hosts file -127.0.0.1  localhost +#this is a comment in the hosts file +127.0.0.1 localhost -192.168.0.1 sample.test #a comment -192.160.0.200 try.sample.test try #another comment -216.58.223.238 google.com +192.168.0.1 sample.test #a comment +192.160.0.200 try.sample.test try #another comment +216.58.223.238 google.com -::1 localhost.try ip6-localhost +::1 localhost.try ip6-localhost