Skip to content

Commit

Permalink
Merge branch 'master' into print
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 authored Nov 14, 2024
2 parents ca43c7a + 822eff6 commit 6598442
Show file tree
Hide file tree
Showing 26 changed files with 855 additions and 154 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/*.rs.bk

# Generated files
/assets/completions/_bat.ps1
/assets/completions/bat.bash
/assets/completions/bat.fish
/assets/completions/bat.zsh
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar)
- `bat --strip-ansi={never,always,auto}` to remove ANSI escape sequences from bat's input, see #2999 (@eth-p)
- Add or remove individual style components without replacing all styles #2929 (@eth-p)
- Automatically choose theme based on the terminal's color scheme, see #2896 (@bash)
- Add option `--binary=as-text` for printing binary content, see issue #2974 and PR #2976 (@einfachIrgendwer0815)

## Bugfixes
Expand Down Expand Up @@ -63,7 +64,9 @@
- Associate Wireguard config `/etc/wireguard/*.conf`, see #2874 (@cyqsimon)
- Add support for [CFML](https://www.adobe.com/products/coldfusion-family.html), see #3031 (@brenton-at-pieces)
- Map `*.mkd` files to `Markdown` syntax, see issue #3060 and PR #3061 (@einfachIrgendwer0815)
- Add syntax mapping for CITATION.cff, see #3103 (@Ugzuzg)
- Add syntax mapping for kubernetes config files #3049 (@cyqsimon)
- Adds support for pipe delimiter for CSV #3115 (@pratik-m)
- Add syntax mapping for `/etc/pacman.conf` #2961 (@cyqsimon)

## Themes
Expand All @@ -76,6 +79,9 @@
- [BREAKING] `SyntaxMapping::mappings` is replaced by `SyntaxMapping::{builtin,custom,all}_mappings`
- Make `Controller::run_with_error_handler`'s error handler `FnMut`, see #2831 (@rhysd)
- Improve compile time by 20%, see #2815 (@dtolnay)
- Add `theme::theme` for choosing an appropriate theme based on the
terminal's color scheme, see #2896 (@bash)
- [BREAKING] Remove `HighlightingAssets::default_theme`. Use `theme::default_theme` instead.
- Add `PrettyPrinter::print_with_writer` for custom output destinations, see #3070 (@kojix2)

# v0.24.0
Expand Down Expand Up @@ -115,6 +121,7 @@
- Update `Julia` syntax, see #2553 (@dependabot)
- add `NSIS` support, see #2577 (@idleberg)
- Update `ssh-config`, see #2697 (@mrmeszaros)
- Add syntax mapping `*.debdiff` => `diff`, see #2947 (@jacg)

## `bat` as a library

Expand Down
80 changes: 61 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ minimal-application = [
]
git = ["git2"] # Support indicating git modifications
paging = ["shell-words", "grep-cli"] # Support applying a pager on the output
lessopen = ["run_script", "os_str_bytes"] # Support $LESSOPEN preprocessor
lessopen = ["run_script", "os_str_bytes/conversions"] # Support $LESSOPEN preprocessor
build-assets = ["syntect/yaml-load", "syntect/plist-load", "regex", "walkdir"]

# You need to use one of these if you depend on bat as a library:
Expand All @@ -58,16 +58,17 @@ serde_derive = "1.0"
serde_yaml = "0.9.28"
semver = "1.0"
path_abs = { version = "0.5", default-features = false }
clircle = "0.5"
clircle = "0.6"
bugreport = { version = "0.5.0", optional = true }
etcetera = { version = "0.8.0", optional = true }
grep-cli = { version = "0.1.10", optional = true }
grep-cli = { version = "0.1.11", optional = true }
regex = { version = "1.10.2", optional = true }
walkdir = { version = "2.5", optional = true }
bytesize = { version = "1.3.0" }
encoding_rs = "0.8.34"
encoding_rs = "0.8.35"
os_str_bytes = { version = "~7.0", optional = true }
run_script = { version = "^0.10.1", optional = true}
terminal-colorsaurus = "0.4"

[dependencies.git2]
version = "0.19"
Expand Down Expand Up @@ -109,7 +110,7 @@ regex = "1.10.2"
serde = "1.0"
serde_derive = "1.0"
serde_with = { version = "3.8.1", default-features = false, features = ["macros"] }
toml = { version = "0.8.9", features = ["preserve_order"] }
toml = { version = "0.8.19", features = ["preserve_order"] }
walkdir = "2.5"

[build-dependencies.clap]
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsors</a>
<a href="https://www.warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=bat_20231001">
<img src="doc/sponsors/warp-logo.png" width="200" alt="Warp">
<br>
<strong>Warp is a modern, Rust-based terminal with AI built in<br>so you and your team can build great software, faster.</strong>
<strong>Warp, the intelligent terminal</strong>
<br>
<sub>Feel more productive on the command line with parameterized commands,</sub>
<sub>Run commands like a power user with AI and your dev team’s</sub>
<br>
<sup>autosuggestions, and an IDE-like text editor.</sup>
<sup>knowledge in one fast, intuitive terminal. For MacOS or Linux.</sup>
</a>

### Syntax highlighting
Expand Down Expand Up @@ -482,8 +482,10 @@ the following command (you need [`fzf`](https://github.com/junegunn/fzf) for thi
bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
```

`bat` looks good on a dark background by default. However, if your terminal uses a
light background, some themes like `GitHub` or `OneHalfLight` will work better for you.
`bat` automatically picks a fitting theme depending on your terminal's background color.
You can use the `--theme-light` / `--theme-light` options or the `BAT_THEME_DARK` / `BAT_THEME_LIGHT` environment variables
to customize the themes used. This is especially useful if you frequently switch between dark and light mode.

You can also use a custom theme by following the
['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes).

Expand Down Expand Up @@ -693,10 +695,11 @@ on your operating system. To get the default path for your system, call
bat --config-file
```

Alternatively, you can use the `BAT_CONFIG_PATH` environment variable to point `bat` to a
non-default location of the configuration file:
Alternatively, you can use `BAT_CONFIG_PATH` or `BAT_CONFIG_DIR` environment variables to point `bat`
to a non-default location of the configuration file or the configuration directory respectively:
```bash
export BAT_CONFIG_PATH="/path/to/bat.conf"
export BAT_CONFIG_PATH="/path/to/bat/bat.conf"
export BAT_CONFIG_DIR="/path/to/bat"
```

A default configuration file can be created with the `--generate-config-file` option.
Expand Down
2 changes: 2 additions & 0 deletions assets/completions/_bat.ps1.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -Script
[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.')
Expand Down
9 changes: 9 additions & 0 deletions assets/completions/bat.bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ _bat() {
return 0
;;
--theme)
local IFS=$'\n'
COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --list-themes)" -- "$cur"))
__bat_escape_completions
return 0
;;
--theme-dark | \
--theme-light)
local IFS=$'\n'
COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur"))
__bat_escape_completions
Expand Down Expand Up @@ -170,6 +177,8 @@ _bat() {
--map-syntax
--ignored-suffix
--theme
--theme-dark
--theme-light
--list-themes
--squeeze-blank
--squeeze-limit
Expand Down
14 changes: 13 additions & 1 deletion assets/completions/bat.fish.in
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ set -l tabs_opts '
8\t
'

set -l special_themes '
auto\tdefault,\ Choose\ a\ theme\ based\ on\ dark\ or\ light\ mode
auto:always\tChoose\ a\ theme\ based\ on\ dark\ or\ light\ mode
auto:system\tChoose\ a\ theme\ based\ on\ dark\ or\ light\ mode
dark\tUse\ the\ theme\ specified\ by\ --theme-dark
light\tUse\ the\ theme\ specified\ by\ --theme-light
'

# Completions:

complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg
Expand Down Expand Up @@ -203,7 +211,11 @@ complete -c $bat -l tabs -x -a "$tabs_opts" -d "Set tab width" -n __bat_no_excl_

complete -c $bat -l terminal-width -x -d "Set terminal <width>, +<offset>, or -<offset>" -n __bat_no_excl_args

complete -c $bat -l theme -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme" -n __bat_no_excl_args
complete -c $bat -l theme -x -a "$special_themes(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme" -n __bat_no_excl_args

complete -c $bat -l theme-dark -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme for dark backgrounds" -n __bat_no_excl_args

complete -c $bat -l theme-light -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme for light backgrounds" -n __bat_no_excl_args

complete -c $bat -s V -l version -f -d "Show version information" -n __fish_is_first_arg

Expand Down
Loading

0 comments on commit 6598442

Please sign in to comment.