diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /bat | |
download | cli-tools-windows-master.tar.gz cli-tools-windows-master.tar.bz2 cli-tools-windows-master.zip |
Diffstat (limited to 'bat')
-rw-r--r-- | bat/CHANGELOG.md | 1044 | ||||
-rw-r--r-- | bat/LICENSE-APACHE | 201 | ||||
-rw-r--r-- | bat/LICENSE-MIT | 19 | ||||
-rw-r--r-- | bat/README.md | 808 | ||||
-rw-r--r-- | bat/autocomplete/_bat.ps1 | 92 | ||||
-rw-r--r-- | bat/autocomplete/bat.bash | 101 | ||||
-rw-r--r-- | bat/autocomplete/bat.fish | 219 | ||||
-rw-r--r-- | bat/autocomplete/bat.zsh | 99 | ||||
-rw-r--r-- | bat/bat.1 | 238 | ||||
-rw-r--r-- | bat/bat.exe | bin | 0 -> 6008832 bytes |
10 files changed, 2821 insertions, 0 deletions
diff --git a/bat/CHANGELOG.md b/bat/CHANGELOG.md new file mode 100644 index 0000000..a8245e0 --- /dev/null +++ b/bat/CHANGELOG.md @@ -0,0 +1,1044 @@ +# v0.22.1 + +## Bugfixes + +- Bring back pre-processing of ANSI escape characters to so that some common `bat` use cases starts working again. See #2308 (@Enselic) + + +# v0.22.0 + +## Features + +- Make the default macOS theme depend on Dark Mode. See #2197, #1746 (@Enselic) +- Support for separate system and user config files. See #668 (@patrickpichler) + +## Bugfixes + +- Prevent fork nightmare with `PAGER=batcat`. See #2235 (@johnmatthiggins) +- Make `--no-paging`/`-P` override `--paging=...` if passed as a later arg, see #2201 (@themkat) +- `--map-syntax` and `--ignored-suffix` now works together, see #2093 (@czzrr) +- Strips byte order mark from output when in non-loop-through mode. See #1922 (@dag-h) + +## Other + +- Relaxed glibc requirements on amd64, see #2106 and #2194 (@sharkdp) +- Improved fish completions. See #2275 (@zgracem) +- Stop pre-processing ANSI escape characters. Syntax highlighting on ANSI escaped input is not supported. See #2185 and #2189 (@Enselic) + +## Syntaxes + +- NSE (Nmap Scripting Engine) is mapped to Lua, see #2151 (@Cre3per) +- Correctly color `fstab` dump and pass fields, see #2246 (@yuvalmo) +- Update `Command Help` syntax, see #2255 +- `Julia`: Fix syntax highlighting for function name starting with `struct`, see #2230 +- Minor update to `LiveScript`, see #2291 +- Associate `.mts` and `.cts` files with the `TypeScript` syntax. See #2236 (@kidonng) +- Fish history is mapped to YAML. See #2237 (@kidonng) + +## `bat` as a library + +- Make `bat::PrettyPrinter::syntaxes()` iterate over new `bat::Syntax` struct instead of `&syntect::parsing::SyntaxReference`. See #2222 (@Enselic) +- Clear highlights after printing, see #1919 and #1920 (@rhysd) + + +# v0.21.0 + +## Features + +- Correctly render tab stops in `--show-all`, see #2038 (@Synthetica9) +- Add a `--style=default` option and make it the default. It is less verbose than `full`, see #2061 (@IsaacHorvath) +- Enable BusyBox `less` as pager, see #2162 (@nfisher1226) +- File extensions are now matched case-insensitively. See #1854, #2181 (@Enselic) + +## Bugfixes + +- Bump `regex` dependency from 1.5.4 to 1.5.5 to fix [CVE-2022-24713](https://blog.rust-lang.org/2022/03/08/cve-2022-24713.html), see #2145, #2139 (@Enselic) +- `bat` no longer crashes when encountering files that references missing syntaxes. See #915, #2181 (@Enselic) + +## Performance + +- Skip syntax highlighting on long lines (> 16384 chars) to help improve performance. See #2165 (@keith-hall) +- Vastly improve startup time by lazy-loading syntaxes via syntect 5.0.0. This makes bat display small files ~75% faster than before. See #951, #2181 (@Enselic) + +## Other + +- Include info about custom assets in `--diagnostics` if used. See #2107, #2144 (@Enselic) + +## Syntaxes + +- Mapped clang-format config file (.clang-format) to YAML syntax (@TruncatedDinosour) +- log syntax: improved handling of escape characters in double quoted strings. See #2123 (@keith-hall) +- Associate `/var/spool/mail/*` and `/var/mail/*` with the `Email` syntax. See #2156 (@cyqsimon) +- Added cmd-help syntax to scope --help messages. See #2148 (@victor-gp) +- Slightly adjust Zig syntax. See #2136 (@Enselic) +- Associate `.inf` files with the `INI` syntax. See #2190 (@Enselic) + +## `bat` as a library + +- Allow configuration of `show_nonprintable` with `PrettyPrinter`, see #2142 +- The binary format of syntaxes.bin has been changed due to syntaxes now being lazy-loaded via syntect 5.0.0. See #2181 (@Enselic) +- Mark `bat::error::Error` enum as `#[non_exhaustive]` to allow adding new variants without future semver breakage. See #2181 (@Enselic) +- Change `Error::SyntectError(syntect::LoadingError)` to `Error::SyntectError(syntect::Error)`. See #2181 (@Enselic) +- Add `Error::SyntectLoadingError(syntect::LoadingError)` enum variant. See #2181 (@Enselic) + + +# v0.20.0 + +## Features + +- New style component `header-filesize` to show size of the displayed file in the header. See #1988 (@mdibaiee) +- Use underline for line highlighting on ANSI, see #1730 (@mdibaiee) + +## Bugfixes + +- Fix bash completion on bash 3.x and bash-completion 1.x. See #2066 (@joshpencheon) + +## Syntaxes + +- `GraphQL`: Add support for interfaces implementing interfaces and consider ampersand an operator. See #2000 +- Associate `_vimrc` and `_gvimrc` files with the `VimL` syntax. See #2002 +- Associate `poetry.lock` files with the `TOML` syntax. See #2049 +- Associate `.mesh`, `.task`, `.rgen`, `.rint`, `.rahit`, `.rchit`, `.rmiss`, and `.rcall` with the `GLSL` syntax. See #2050 +- Added support for `JQ` syntax, see #2072 +- Properly associate global git config files rooted in `$XDG_CONFIG_HOME/git/` or `$HOME/.config/git/`. See #2067 (@cyqsimon) + +## `bat` as a library + +- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison) +- Added `HeaderFilename` and `HeaderFilesize` to `StyleComponent` enum, and mark it `#[non_exhaustive]`. See #1988 (@mdibaiee) + + +# v0.19.0 + +## Performance + +- Reduce startup time in loop-through mode (e.g. when redirecting output) by 90%. See #1747 (@Enselic) +- Load themes lazily to make bat start 25% faster when disregarding syntax load time. See #1969 (@Enselic) +- Python syntax highlighting no longer suffers from abysmal performance in specific scenarios. See #1688 (@keith-hall) +- Fix for poor performance when ANSI escape sequences are piped to `bat`, see #1596 (@eth-p) +- Fix for incorrect handling of ANSI escape sequences when using `--wrap=never`, see #1596 (@eth-p) +- Load custom assets as fast as integrated assets, see #1753 (@Enselic) + +## Features + +- Support for `x:-delta` (minus) syntax in line ranges (e.g. `20:-10`). See #1901 (@bojan88) +- Support for `--ignored-suffix` argument. See #1892 (@bojan88) +- `$BAT_CONFIG_DIR` is now a recognized environment variable. It has precedence over `$XDG_CONFIG_HOME`, see #1727 (@billrisher) +- Support for `x:+delta` syntax in line ranges (e.g. `20:+10`). See #1810 (@bojan88) +- Add new `--acknowledgements` option that gives credit to theme and syntax definition authors. See #1971 (@Enselic) +- Include git hash in `bat -V` and `bat --version` output if present. See #1921 (@Enselic) + +## Bugfixes + +- First line not shown in diff context. See #1891 (@divagant-martian) +- Do not ignore syntaxes that handle file names with a `*.conf` extension. See #1703 (@cbolgiano) + +## Other + +- Add PowerShell completion, see #1826 (@rashil2000) +- Minimum supported Rust version (MSRV) bumped to 1.51, see #1994 (@mdibaiee) + +## Syntaxes + +- Groff, see #1685 (@scop) +- HTTP Requests and Responses, see #1748 (@keith-hall) +- LLVM, see #1777 (@ioncodes) +- Highlight for `vimrc` and `gvimrc` files, see #1763 (@SuperSandro2000) +- Syslog highlighting improvements, see #1793 (@scop) +- Added support for `slim` syntax, see #1693 (@mfinelli) +- Racket, see #1884 (@jubnzv) +- LiveScript, see #1915 (@Enselic) +- MediaWiki, see #1925 (@sorairolake) +- The `requirements.txt` syntax has been removed due to incompatible license requirements. +- Dart, new highlighter, see #1959 (@Ersikan) +- SCSS and Sass syntaxes updated, see #1766 (@Enselic) +- PowerShell syntax updated, see #1935 (@Enselic) +- TypeScript syntax updated, see #1834 (@Enselic) + +## `bat` as a library + +- Deprecate `HighlightingAssets::syntaxes()` and `HighlightingAssets::syntax_for_file_name()`. Use `HighlightingAssets::get_syntaxes()` and `HighlightingAssets::get_syntax_for_path()` instead. They return a `Result` which is needed for upcoming lazy-loading work to improve startup performance. They also return which `SyntaxSet` the returned `SyntaxReference` belongs to. See #1747, #1755, #1776, #1862 (@Enselic) +- Remove `HighlightingAssets::from_files` and `HighlightingAssets::save_to_cache`. Instead of calling the former and then the latter you now make a single call to `bat::assets::build`. See #1802, #1971 (@Enselic) +- Replace the `error::Error(error::ErrorKind, _)` struct and enum with an `error::Error` enum. `Error(ErrorKind::UnknownSyntax, _)` becomes `Error::UnknownSyntax`, etc. Also remove the `error::ResultExt` trait. These changes stem from replacing `error-chain` with `thiserror`. See #1820 (@Enselic) +- Add new `MappingTarget` enum variant `MapExtensionToUnknown`. Refer to its documentation for more information. Also mark `MappingTarget` as `#[non_exhaustive]` since more enum variants might be added in the future. See #1703 (@cbolgiano), #2012 (@Enselic) + + +# v0.18.3 + +## Bugfixes + +- Bump `git2` dependency to fix build with Rust 1.54, see #1761 + + +# v0.18.2 + +## Features + +- Ignore known backup/template filename suffixes when selecting the syntax, see #1687 (@scop) + +## Bugfixes + +- Fix for a security vulnerability on Windows. Prior to this release, `bat` would execute programs called `less`/`less.exe` from the current working directory (instead of the one from `PATH`) with priority. An attacker might be able to use this by placing a malicious program in a shared directory where the user would execute `bat`. `bat` users on Windows are advised to upgrade to this version. See #1724 and #1472 (@Ry0taK). + +## Other + +- Add bash completion, see #1678 (@scop) +- Fix Clippy lints, see #1661 (@mohamed-abdelnour) +- Add syntax highlighting test files, see #1213 and #1668 (@mohamed-abdelnour) + +## Syntaxes + +- Upgraded Julia syntax to fix a highlighting bug, see #1692 +- Added support for `dash` syntax, see #1654 (@mohamed-abdelnour) +- Added support for `XAML` syntax, see #1590 and #1655 (@mohamed-abdelnour) +- Apply `DotENV` syntax also for `.env.default` and `.env.defaults` files, see #1669 + + +# v0.18.1 + +## Bugfixes + +- Mouse support and screen clearing broken for `less` versions with minor version number (581.2), see #1629 and #1639 (@aswild) + +## Other + +- `Input::ordinary_file` and `Input::with_name` now accept `Path` rather than `OsStr` see #1571 (@matklad) +- The `LESS` environment variable is now included in `bat --diagnostic`, see #1589 (@Enselic) +- Increased min. required Rust version to 1.45 + +## Syntaxes + +- Improved the Syslog syntax highlighting, see #1606 (@keith-hall) +- Replaced "Advanced CSV" with a custom CSV syntax definition written especially for `bat`; see #1574 (@keith-hall) +- Added SystemVerilog file syntax, see #1580 (@SeanMcLoughlin) +- Added Solidity and Vyper syntax, see #1602 (@Ersikan) + +## New themes + +- Dark+ VS Code theme, see #1588 and #1598 (@PatriotRossii) + + + +# v0.18.0 + +## Features + +- Use a pager when `bat --list-languages` is called, see #1394 (@stku1985) + +## Bugfixes + +- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic) +- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube) +- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic) +- VimL syntax highlighting fix, see #1450 (@esensar) +- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic) +- If plain mode is set and wrap is not explicitly opted in, long lines will no be truncated, see #1426 +- If `PAGER` (but not `BAT_PAGER` or `--pager`) is `more` or `most`, silently use `less` instead to ensure support for colors, see #1063 (@Enselic) +- If `PAGER` is `bat`, silently use `less` to prevent recursion. For `BAT_PAGER` or `--pager`, exit with error, see #1413 (@Enselic) +- Manpage highlighting fix, see #1511 (@keith-hall) +- `BAT_CONFIG_PATH` ignored by `bat` if non-existent, see #1550 (@sharkdp) + +## Other + +- Performance improvements, see #1421 (@LovecraftianHorror) +- Added a new `--diagnostic` option to collect information for bug reports, see #1459 (@sharkdp) +- Modified default theme colors to differentiate between a JSON key and a string value, see #1400 (@keith-hall) +- Upped min required Rust version to 1.42 + +## Syntaxes + +- Added Zig syntax, see #1470 (@paulsmith) +- Added Lean syntax, see #1446 (@Julian) +- Added `.resource` extension for Robot Framework files, see #1386 +- Added `gnuplot` syntax, see #1431 (@sharkdp) +- Highlight *.pac (Proxy auto-config) files as JavaScript, see #1515 (@sharkdp) + +## New themes + +- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12). **Breaking change:** users that were previously using one of the `ansi-*` themes should switch to `ansi`. +- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously using `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead. + +## `bat` as a library + +- The following `PrettyPrinter` methods have been removed (they were previously deprecated): + - `input_stdin_with_name` + - `input_from_bytes_with_name` + - `input_from_reader_with_name` + - `vcs_modification_markers` (if the `git` feature is not enabled) + + +# v0.17.1 + +## Bugfixes + +- Running `bat` without arguments fails ("output file is also an input"), see #1396 + + +# v0.17.0 + +## Features + +- Added a new `--style` value, `rule`, which adds a simple horizontal ruled line between files, see #1276 (@tommilligan) +- Pass `-S` ("chop long lines") to `less` if `--wrap=never` is set in `bat`, see #1255 (@gahag) + +## Bugfixes + +- Detect infinite loop when input and output are the same, see #1193 and #1197 (@niklasmohrin) +- Throw an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera) +- Bash syntax highlighting not selected for `*.ebuild` and `*.eclass` files, see #1292 (@sharkdp) +- Fix `zsh` completion when using `-p`, see #1320 (@xzfc) + +## Other + +- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil) +- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera) + +## Syntaxes + +- Manpage syntax highlighting has been improved, see #1315 (@keith-hall) +- Add Svelte file syntax, see #1285 (@kjmph) + +## New themes + +- Coldark, see #1329 (@armandphilippot) + + +# v0.16.0 + +## Features + +- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p) +- Added `-P` short flag to disable paging, see #1075 and #1082 (@LordFlashmeow) +- Added `--force-colorization`/`-f` flag to provide an alias for forced color and decoration output, see #1141 (@alexanderkarlis) + +## Bugfixes + +- Fixed non-printable characters display for redirected output, see #1061 (@gsomix) +- Handle file extension conflicts in `--list-languages`, see #1076 and #1135 (@Kienyew) + +## Other + +- Switched to "·" (U+00B7) Middle Dot from "•" (U+2022) Bullet for non-printing spaces, see #1056 and #1100 (@LordFlashmeow) +- Added zsh shell completion script, see #1136 (@Kienyew) +- Improved `--help` text (@sharkdp) +- Added custom languages/themes sections to manpage (@eth-p) + +## Syntaxes + +- Update AsciiDoc syntax, see #1034 (@rxt1077) +- GLSL (@caioalonso) +- Add Nginx and Apache config file syntax, see #1137 (@kjmph, @niklasmohrin) +- Use `fstab` syntax for `crypttab` files, see #1073 (@sharkdp) +- Support syntax highlighting for files in `$XDG_CONFIG_HOME/git/`, see #1191 (@ahmedelgabri) + +## New themes + +- Gruvbox, see #1069 (@kyleondy) +- base16-256 for [base16-shell](https://github.com/chriskempson/base16-shell) users, see #1111 (@mk12) + +## `bat` as a library + +- Add APIs to provide `Input` descriptions with `InputDescription` (@eth-p) +- Add function to directly provide `Input`s to `PrettyPrinter` (@eth-p) +- **Breaking:** `Input::theme_preview_file` is no longer available. (@eth-p) + +## Packaging + +- Removed build dependency on `liquid` (@sharkdp). + +# v0.15.4 + +## Bugfixes + +- Added missing Solarized themes, see #1027 +- Fixed highlighting bug in Haskell source files, see #1026 + +# v0.15.3 + +## Bugfixes + +- Cannot run `bat` with relative paths, see #1022 +- bat mishighlights Users that start with digits in SSH config, see #984 + +## New syntaxes + +- SML, see #1005 (@kopecs) + +## Other + +- Some syntaxes and themes have been updated to the latest version + +# v0.15.2 + +## Bugfixes + +- Fix syntax detection for files called 'rails', see #1008 +- Fix potential errors with syntax detection for symlinked files, see #1001 +- `--map-syntax` doesn't work with names provided through `--file-name` (@eth-p) + +## Other + +- Add padding above headers when not using a grid, see #968 and #981 (@pt2121) +- bat now prints an error if an invalid syntax is specified via `-l` or `--map-syntax`, see #1004 (@eth-p) + +## `bat` as a library + +- `PrettyPrinter::vcs_modification_markers` has been marked deprecated when building without the `git` feature, see #997 and #1020 (@eth-p, @sharkdp) + +## Packaging + +- Compilation problems with `onig_sys` on various platforms have been resolved by upgrading to `syntect 4.2`, which includes a new `onig` version that allows to build `onig_sys` without the `bindgen` dependency. This removes the need for `libclang(-dev)` to be installed to compile `bat`. Package maintainers might want to remove `clang` as a build dependency. See #650 for more details. + +# v0.15.1 + +## Bugfixes + +- Fix highlighting of Markdown files, see #963 and #977 +- Fix `base16` theme (was broken since in v0.14), see #972, #934 and #979 (@mk12). + Users suffering from #865 ("no color for bat in ssh from a Windows client") can use the `ansi-dark` and `ansi-light` themes from now on. + +## New syntaxes + +- Fortran, see #957 +- Email (@mariozaizar) +- QML, see #962 (@pylipp) + +# v0.15.0 + +## Features + +- Add a new `--diff`/`-d` option that can be used to only show lines surrounding + Git changes, i.e. added, removed or modified lines. The amount of additional + context can be controlled with `--diff-context=N`. See #23 and #940 + +## Bugfixes + +- Error message printed in the middle of the output for another file, see #946 +- Performance improvements when using custom caches (via `bat cache --build`): the `bat` startup time should now be twice as fast (@lzutao). + +## Themes + +- Updated version of the Solarized dark/light themes, see #941 + +## `bat` as a library + +- There are a few changes in the "low level" API (the `Config` struct has changed and + the error handler needs a new `&mut dyn Write` argument). The high-level API is not + affected. + +# v0.14.0 + +## Features + +- Added a new `--file-name <name>…` option to overwrite the displayed filename(s) + in the header. This is useful when piping input into `bat`. See #654 and #892 (@neuronull). +- Added a new `--generate-config-file` option to create an initial configuration file + at the right place. See #870 (@jmick414) + +## Bugfixes + +- Performance problems with C# source code have been fixed, see #677 (@keith-hall) +- Performance problems with Makefiles have been fixed, see #750 (@keith-hall) +- Fix bug when highlighting Ruby files with unindented heredocs, see #914 (@keith-hall) +- A highlighting problem with Rust source code has been fixed, see #924 (@keith-hall) +- Windows: short files that do not require paging are displayed and then lost, see #887 +- `--highlight-line` did not work correctly in combination with `--tabs=0` and `--wrap=never`, + see #937 + +## Other + +- When saving/reading user-provided syntaxes or themes, `bat` will now maintain a + `metadata.yaml` file which includes information about the `bat` version which was + used to create the cached files. When loading cached files, we now print an error + if they have been created with an incompatible version. See #882 +- Updated `liquid` dependency to 0.20, see #880 (@ignatenkobrain) + +## `bat` as a library + +- A completely new "high level" API has been added that is much more convenient + to use. See the `examples` folder for the updated code. The older "low level" + API is still available (basically everything that is not in the root `bat` + module), but has been refactored quite a bit. It is recommended to only use + the new "high level" API, if possible. This will be much easier to keep stable. + Note that this should still be considered a "beta" release of `bat`-as-a-library. + For more details and some screenshots of the example programs, see #936. +- Stripped out a lot of binary-only dependencies, see #895 and #899 (@dtolnay) + + This introduces a `features = ["application"]` which is enabled by default and pulls in + everything required by `bat` the application. When depending on bat as a library, downstream + `Cargo.toml` should disable this feature to cut out inapplicable heavy dependencies: + ``` toml + [dependencies] + bat = { version = "0.14", default-features = false } + ``` + Other optional functionality has also been put behind features: `paging` and `git` support. +- Allow using the library with older syntect, see #896 and #898 (@dtolnay) + +## New syntaxes + +- Rego, see #872 (@patrick-east) +- Stylo, see #917 + + +# v0.13.0 + +## `bat` as a library + +Beginning with this release, `bat` can be used as a library (#423). + +This was a huge effort and I want to thank all people who made this possible: @DrSensor, @mitsuhiko, @mre, @eth-p! + +- Initial attempt in #469 (@mitsuhiko) +- Second attempt, complete restructuring of the `bat` crate, see #679 (@DrSensor) +- Updates to example, public API, error handling, further refactoring: #693 #873 #875 (@sharkdp) + +I want to stress that this is the very first release of the library. Things are very likely to change. A lot of things are still missing (including the documentation). + +That being said, you can start using it! See the example programs in [`examples/`](https://github.com/sharkdp/bat/tree/master/examples). + +You can see the API documentation here: https://docs.rs/bat/ + +## Features + +- (**Breaking change**) Glob-based syntax mapping, see #877 and #592. With this change, + users need to update their bat config files (`bat --config-file`), if they have any `--map-syntax` settings + present. + + The option now works like this: + ```bash + --map-syntax <glob-pattern>:<syntax-name> + ``` + + For more information, see the `--help` text, the man page or the README. + + This new feature allows us to properly highlight files like: + * `/etc/profile` + * `~/.ssh/config` + +- `--highlight-line` now accepts line ranges, see #809 (@lkalir) +- Proper wrapping support for output with wide Unicode characters, see #811 #787 and #815 (@Kogia-sima) +- A lot of updates to existing syntaxes via #644 (@benwaffle, @keith-hall) +- `BAT_CACHE_PATH` can be used to place cached `bat` assets in a non-standard path, see #829 (@neuronull) +- Support combination of multiple styles at the same time, see #857 (@aslpavel) + +## Bugfixes + +- Do not pass '--no-init' on newer less versions, see #749 and #786 (@sharkdp) +- 'bat cache' still takes precedence over existing files, see #666 (@sharkdp) +- `.sc` files should be treated as scala files, see #443 (@benwaffle) +- Allow underscores and dashes in page names, see #670 (@LunarLambda) +- Keep empty lines empty, see #601 (@mbarbar) +- Wrapping does not work when piping, see #758 (@fusillicode, @allevo, @gildo) +- Allow for non-unicode filenames, see #225 (@sharkdp) +- Empty file without header produces incomplete grid, see #798 (@eth-p) +- Files named `build` don't respect shebang lines, see #685 (@sharkdp) + +## Other + +- Parametrizable names for man page and shell completion files, see #659 #673 #656 (@eth-p) +- Enabled LTO, making `bat` about 10% faster, see #719 (@bolinfest, @sharkdp) +- Suggestions non how to configure `bat` for MacOS dark mode, see README (@jerguslejko) +- Extended ["Integration with other tools"](https://github.com/sharkdp/bat#integration-with-other-tools) section (@eth-p) +- Updated [instrutions on how to use `bat` as a `man`-pager](https://github.com/sharkdp/bat#man), see #652, see #667 (@sharkdp) +- Add section concerning file encodings, see #688 and #568 (@sharkdp) +- Updated sort order of command-line options in `--help` text and manpage, see #653 and #700 (@hrlmartins) +- Updates to the man page syntax, see #718 (@sharkdp) +- Japanese documentation updates, see #863 (@k-ta-yamada, @sorairolake and @wt-l00) +- Accept "default" as a theme, see #757 (@fvictorio) +- Updated Windows installation instructions, see #852 (@sorenbug) +- Updated man page, see #573 (@sharkdp) + +## New syntaxes + +- Jinja2, see #648 (@Martin819) +- SaltStack SLS, see #658 (@Martin819) +- `/etc/fstab`, see #696 (@flopp and @eth-p) +- `/etc/group` and `/etc/passwd`, see #698 (@argentite) +- `/proc/cpuinfo` and `/proc/meminfo`, see #593 (@sharkdp) +- Nim, see #542 (@sharkdp) +- Vue, see #826 (@chaaaaarlotte) +- CoffeScript, see #833 (@sharkdp) + +## New themes + +- Dracula, see #687 (@clarfon) +- Nord, see #760 (@crabique) +- Solarized light and dark, see #768 (@hakamadare) + +## Packaging + +- `bat` is now in the official Ubuntu and Debian repositories, see #323 and #705 (@MarcoFalke) +- `bat` can now be installed via MacPorts, see #675 (@bn3t) +- Install fish completions into 'vendor_completions.d', see #651 (@sharkdp) + +## Thanks + +- To @eth-p for joining me as a maintainer! I'm very grateful for all the work you put into + managing and responding to issues, improving our deployment, adding PR/issue templates (#837) as + well as fixing bugs and implementing new features. + +# v0.12.1 + +## Bugfixes + +- Fixes a bug for older Windows versions (*"The procedure entry point `CreateFile2` could not be located"*), see #643 (@rivy) + +# v0.12.0 + +## Features + +- Binary file content can now be viewed with `bat -A`, see #623, #640 (@pjsier and @sharkdp) +- `bat` can now be used as a man pager. Take a look at the README and #523 for more details. +- Add new style component to separate multiple `--line-range`s, see #570 (@eth-p) +- Added `-L` as an alias for `--list-languages` + +## Bugfixes + +- Output looks unbalanced when using '--style=grid,numbers' without 'header', see #571 (@eth-p) +- issues with filenames starting with "cache", see #584 +- Can't build cache with new theme without creating cache dir, see #576 (@frm) +- `--terminal-width -10` is parsed incorrectly, see #611 + +## Other + +- Added fish completions to DEB package, see #554 + +## New syntaxes + +- Emacs Org mode, see #36 (@bricewge) +- `requirements.txt` +- DotENV `.env` +- SSH config syntax (`-l ssh_config`), see #582 (@issmirnov) +- `/etc/hosts`, see #583 (@issmirnov) +- GraphQL, see #625 (@dandavison) +- Verilog, see #616 +- SCSS and Sass, see #637 +- `strace` syntax, see #599 + +## Packaging + +- `bat` is now in the official Gentoo repositories, see #588 (@toku-sa-n) +- `bat` is now in the official Alpine Linux repositories, see #586 (@5paceToast) +- `bat` is in the official Fedora repositories, see #610 (@ignatenkobrain) + +# v0.11.0 + +## Features + +- Three new special color themes are available: `ansi-light`, `ansi-dark` and `base16`. These + are useful for people that often switch from dark to light themes in their terminal emulator + or for people that want the colors to match their terminal theme colors. For more details, + see #543 and #490 (@mk12, implementation idea by @trishume) +- Hand-written auto completion script for Fish shell, see #524 and #555 (@ev-dev and @eth-p) +- The `-p`/`--plain` option can now be used twice (typically `-pp`). The first `-p` switches the + `--style` to "plain". The second `-p` disables the pager. See #560 and #552 (@eth-p) + +## Bugfixes + +- Do not replace arguments to `less` when using `--pager`, see #509 +- Binary files will now be indicated by a warning in interactive mode, see #530 #466 #550 (@maxfilov) +- Empty files are (once again) printed with a single header line, see #504 and #566 (@reidwagner + and @sharkdp) +- `--terminal-width=0` is now disallowed, see #559 (@eth-p) +- Accidental printing of files named `cache`, see #557 + +## Other + +- New integration tests, see #500 and #502 (@reidwagner and @sharkdp) +- New ["Integration with other tools"](https://github.com/sharkdp/bat#integration-with-other-tools) section in the README. +- Migrated to Rust 2018 (@expobrain) + +## New syntaxes + +- F# syntax has been updated, see #531 (@stroborobo) +- Fish shell, see #548 (@sanga) + +## Packaging + +- `bat` is now available on Chocolatey, see #541 (@rasmuskriest) + +# v0.10.0 + +## Features + +- Added new `--highlight-line <N>` option, see #453, #346 and #175 (@tskinn and @sharkdp) + +## Changes + +- **Change the default configuration directory on macOS** to `~/.config/bat`, see #442 (@lavifb). If you are on macOS, you need to copy your configuration directory from the previous place (`~/Library/Preferences/bat`) to the new place (`~/.config/bat`). +- Completely disabled the generation of shell completion files, see #372 +- Properly set arguments to `less` if `PAGER` environment variable contains something like `less -F` (which is missing the `-R` option), see #430 (@majecty) +- Report the name of missing files, see #444 (@ufuji1984) +- Don't start pager if file doesn't exist, see #387 +- Rename `bat cache --init` to `bat cache --build`, see #498 +- Move the `--config-dir` and `--cache-dir` options from `bat cache` to `bat` and hide them from the help text. + +## Bugfixes + +- Blank line at the end of output when using `--style=plain`, see #379 +- EOF must be sent twice on stdin if no other input is sent, see #477 (@reidwagner) + +## New syntaxes + +- Twig (@ahmedelgabri) +- `.desktop` files (@jleclanche) +- AsciiDoc (@markusthoemmes) +- Assembly (x86_64 and ARM) +- Log files (@caos21) +- Protobuf and ProtobufText (@caos21) +- Terraform (@caos21) +- Jsonnet (@hfm) +- Varlink (@haraldh) + +## Other + +- Added Japanese version of README (@sh-tech and @object1037) +- Code improvements (@barskern) + +# v0.9.0 + +## Features + +- A new `-A`/`--show-all` option has been added to show and highlight non-printable characters (in analogy to GNU `cat`s option): + + ![](https://camo.githubusercontent.com/c3e769482ef3184f6be6adaa34bdc8d19c378254/68747470733a2f2f692e696d6775722e636f6d2f324b54486859542e706e67) + + see #395 and #381 for more details. + +- Added `--pager` option (to configure the pager from the configuration file), see #362 (@majecty) + +- Added `BAT_CONFIG_PATH` environment variable to set a non-default path for `bat`s configuration file, see #375 (@deg4uss3r) + +- Allow for multiple occurrences of `--style` to allow for the configuration + of styles from the config file, see #367 (@sindreij) + +- Allow for multiple `--line-range` arguments, see #23 + +- The `--terminal-width` option can now also accept offsets, see #376 + +## Changes + +- Use of italics is now *disabled by default* (see #389 for details). They can be + re-enabled by adding `--italic-text=always` to your configuration file. + +- The default tab-width has been set to 4. + +- Added new "Sublime Snazzy" theme. + +- Shell completions are currently *not* shipped anymore, see #372 for details. + +## Bugfixes + +- Avoid endless recursion when `PAGER="bat"`, see #383 (@rodorgas) + +## Other + +- `bat` is now available on openSUSE, see #405 (@dmarcoux) + +- Added section about the new configuration file in the README (@deg4uss3r) + +- Chinese translation of README (@chinanf-boy) + +- Re-written tests for `--tabs` (@choznerol) + +- Speed up integration tests, see #394 + +# v0.8.0 + +## Features + +- Support for a configuration file with the following simple format: + + ```bash + --tabs=4 + --theme="Sublime Snazzy" + + # A line-comment + --map-syntax .ignore:.gitignore + --map-syntax PKGBUILD:bash + --map-syntax Podfile:ruby + + # Flags and options can also be on a single line: + --wrap=never --paging=never + ``` + + The configuration file path can be accessed via `bat --config-file`. On Linux, + it is stored in `~/.config/bat/config`. + +- Support for the `BAT_OPTS` environment variable with the same format as specified + above (in a single line). This takes precedence over the configuration file. + + See also #310. + +- Support for custom syntax mappings via the `-m`/`--max-syntax` option. + + This allows users to (re)map certain file extensions or file names to an existing syntax: + + ``` bash + bat --map-syntax .config:json ... + ``` + + The option can be use multiple times. Note that you can easily make these mappings permanent by using bats new configuration file. + + See #169 + +- Support pager command-line arguments in `PAGER` and `BAT_PAGER`, see #352 (@Foxboron) + +- Add support for wildcards in Windows CMD, see #309 (@zxey) + +- First-line syntax detection for all input types, see #205 + +- Encoding support for UTF-16LE and UTF-16BE, see #285 + +- New syntaxes: Robot framework (@sanga) + +## Changes + +- Binary files are now detected and not displayed when the output goes to an interactive terminal, see #205 + +## Bugfixes + +- JavaDoc comments break syntax highlighting in .java files, see #81 + +- Bat Panics on Haskell Source Code, see #314 + +## Other + +- Better `-h` and `--help` texts. + +- Updated documentation on how to configure `bat`s pager + +- Updated documentation for light backgrounds, see #328 (@russtaylor) + +- Generate shell completions during build, see #115 (@davideGiovannini) + +- A lot of new tests have been written + +- `bat` is now available via [Termux](https://termux.com/), see #341 (@fornwall) + +- `bat` is now available via [nix](https://nixos.org/nix), see #344 (@mgttlinger) + +- `bat` is now available via [Docker](https://hub.docker.com/r/danlynn/bat/), see #331 (@danlynn) + +# v0.7.1 + +## Features + +- Use the `ansi_colours` package by @mina86 for better true-color approximation on 8 bit color terminals, see #319 and #202. + +## Bugfixes + +- Bat Panics on Haskell Source Code, see #314 +- Disable wrapping when `--style=plain`/`-p` is used, see #289 + +## Other + +- Added Ansible install instructions (@aeimer) +- Added section about Cygwin to the README (@eth-p) + +# v0.7.0 + +## Features + +- Tabs are now (optionally) expanded to spaces. This can be controlled with the new + `--tabs` command-line option or the `BAT_TABS` environment variable. The + new feature also closes two bugs #166 and #184. For more information, see #302 (@eth-p). + +- Added support for the `BAT_STYLE` environment variable, see #208 (@ms2300) + +- Added `OneHalf` theme for terminals with a light-gray background, see #256 + +- Added new syntaxes for CSV, JSX in JavaScript and TypeScript, Cabal, Dart, + F#, PureScript, Swift, Crystal, PowerShell (Many Thanks to @tobenna and @mimadrid) + +## Changes + +- Query `git diff` only when needed, see #303 (@ShikChen) + +- Disable wrapping when `--plain` is used, see #289 (@eth-p) + +## Bugfixes + +- Can read files named `cache`, see #275 (@BK1603) + +- A lot of bugfixes for Windows, see #252, #264 + +- Detect `less` reliably and in a portable way, see #271 and #290 (@Aankhen) + +- last decoration line is not formatted properly with `--wrap never`, see #299 (@Rogach) + +- Do not show file header for directories, see #292 + +## Other + +- Enabled a new `aarch64` build target, see #258 (@rachitchokshi) + +- Provide Debian packages for `armhf`, see #280 (@rachitchokshi) + +- Added README section about "`bat` on Windows" (@Aankhen) + +- Windows installation via scoop (@meltinglava) + +# v0.6.1 + +## Bugfixes + +- Fixed panic when running `bat --list-languages | head`, see #232 (@mchlrhw) +- Respect `--color` settings for `--list-themes` and `--list-languages`, see #233 +- Git modifications now work on Windows + +## Other + +- There will be auto-generated Windows releases, starting with this version (@anykao) + +# v0.6.0 + +## Features + +- The `--list-themes` option now shows a preview for each highlighting theme (@ms2300) +- Added `-p`/`--plain` as an alias for `--style=plain`, see #212 (@ms2300) +- Major refactorings, enabling some progress on #150. In non-interactive mode, `bat` will now copy input bytes 1:1. +- New languages: Elm, Kotlin, Puppet, TypeScript, see #215 #216 #217 #218 +- New syntax highlighting theme: zenburn (@colindean) + +## Changes + +- New themes in `$BAT_CONFIG_DIR/themes` are now loaded *in addition* to + the default themes (they may also override), see #172 +- The `Default.tmTheme` symlink is not necessary anymore. + +## Bugfixes + +* Using `bat cache --init` leads to duplicated syntaxes, see #206 + +## Other + +* Extended and cleaned-up `--help` text. +* Added initial version of a man page, see #52 +* New README sections: *Development* and *Troubleshooting*, see #220 + +# v0.5.0 + +## Features + +- Added `--line-range n:m` option to print a range of lines, see #159 (@tskinn) +- The syntax highlighting theme can now be controlled by the `BAT_THEME` environment variable, see [README](https://github.com/sharkdp/bat#highlighting-theme) and #177 (@mandx) +- The `PAGER` and `BAT_PAGER` environment variables can be used to control the pager that `bat` uses, see #158 and the [new README section](https://github.com/sharkdp/bat#using-a-different-pager) +- Added syntax highlighting for Nix, see #180 +- Added syntax highlighting for AWK (Gert Hulselmans) + +## Changes + +- The customization of syntax sets and theme sets is now separated. Syntax definitions are now loaded *in addition* to the ones that are stored in the `bat` binary by default. Please refer to these new sections in the README: [Adding new syntaxes](https://github.com/sharkdp/bat#adding-new-syntaxes--language-definitions), [Adding new themes](https://github.com/sharkdp/bat#adding-new-themes), also see #172 +- The color for the filename is now the default foreground color. The colors for the grid and the line numbers is now determined from the syntax highlighting theme, which now also works for light backgrounds, see #178. + +## Bugfixes + +- Escape Sequences get partially stripped, see #182 (@eth-p) +- Use separate Git repository for snapshot testing, see #165 and #161 +- Markdown breaking on JavaScript, see #183 + +## Other + +- Binaries for armv7 are now provided, see #196 +- `bat` is now in the official [Arch package repositories](https://www.archlinux.org/packages/community/x86_64/bat/). +- Optimizations in the RGB => 8-bit conversion (@mina86) + +# v0.4.1 + +(this is just a small bugfix release, see 0.4.0 for all features and changes) + +## Bugfixes + +- Fix problem with `cargo test` when `bat` is not checked out in a Git repository, see #161 + +# v0.4.0 + +## Features + +* Support for line-wrapping, see #54 and #102 (@eth-p) +* New and updated `--style` parameter, see #74 and README (@pitkley) +* Added `--theme` and `--list-themes` options, see #89 (@rleungx) +* Added syntax highlighting for: Julia (@iamed2), Dockerfiles, VimL, CMake, INI, Less +* Added a few popular Sublime Text highlighting themes, see #133 +* Support for bold, italic and underline font styles, see #96 +* Support for 32bit systems is now available, see #84 +* Added `-u` and `-n` options, see #134 +* ANSI color support on Windows 10 + +## Changes + +* The customization folder for own syntaxes has been renamed from `syntax` to `syntaxes`, see README. +* Changed Markdown syntax to the default Sublime Text syntax, see #157 +* Sorted language listing (@rleungx) +* Command line arguments like `--theme` or `--color` can now override themselves. +* Improved `--help` text. + +## Bugfixes + +- Fixed crash for (really) small terminal sizes, see #117 (@eth-p) +- Syntax detection for `.bashrc`, `CMakeLists.txt` etc., see #100 +- Properly handle lines with invalid UTF-8, see #7 (@BrainMaestro) +- Better error handling, see #17 (@rleungx and @sharkdp) +- Proper handling of UTF-8 characters in `less`, see #98 (@ghuls) +- Build fix on nightly, see #148 (@tathanhdinh) + +## Other + +- [Comparison with alternative projects](https://github.com/sharkdp/bat/blob/master/doc/alternatives.md). +- New "bat" logo in the README, see #119 (@jraulhernandezi) +- Output test cases (@BrainMaestro) +- Lots of great refactoring work (@BrainMaestro) + +# v0.3.0 + +## Features + +* Automatic paging by integrating with `less`, see #29 (@BrainMaestro) +* Added support for reading from standard input, see #2 +* Added support for writing to non-interactive terminals (pipes, files, ..); new + `--color=auto/always/never` option, see #26 (@BrainMaestro) +* Added `--list-languages` option to print all available syntaxes, see #69 (@connorkuehl) +* New option to specify the syntax via `-l`/`--language`, see #19 (@BrainMaestro) +* New option to control the output style (`--style`), see #5 (@nakulcg) +* Added syntax highlighting support for TOML files, see #37 + +## Changes + +* The `init-cache` sub-command has been removed. The cache can now be controlled via + `bat cache`. See `bat cache -h` for all available commands. + +## Bug fixes + +* Get git repository from file path instead of current directory, see #22 (@nakulcg) +* Process substitution can now be used with bat (`bat <(echo a) <(echo b)`), see #80 + +## Thanks + +I'd like to say a big THANK YOU to all contributors and everyone that has given us +some form of feedback. + +Special thanks go to @BrainMaestro for his huge support with new features, bug reports +and code reviews! + +# v0.2.3 + +- Added a new statically linked version of bat (`..-musl-..`) + +# v0.2.2 + +- Remove openssl dependency completely, see #30. + +# v0.2.1 + +- Added Elixir syntax, see #25. +- Use libcurl-openssl instead of libcurl-gnutls, see #30. + +# v0.2.0 + +- Support for custom syntaxes, add 'Markdown extended' theme +- Bugfix: Git modifications not shown from child folder + +# v0.1.0 + +Initial release diff --git a/bat/LICENSE-APACHE b/bat/LICENSE-APACHE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/bat/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bat/LICENSE-MIT b/bat/LICENSE-MIT new file mode 100644 index 0000000..65e46e1 --- /dev/null +++ b/bat/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2018-2021 bat-developers (https://github.com/sharkdp/bat). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/bat/README.md b/bat/README.md new file mode 100644 index 0000000..b1e2433 --- /dev/null +++ b/bat/README.md @@ -0,0 +1,808 @@ +<p align="center"> + <img src="doc/logo-header.svg" alt="bat - a cat clone with wings"><br> + <a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a> + <img src="https://img.shields.io/crates/l/bat.svg" alt="license"> + <a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br> + A <i>cat(1)</i> clone with syntax highlighting and Git integration. +</p> + +<p align="center"> + <a href="#syntax-highlighting">Key Features</a> • + <a href="#how-to-use">How To Use</a> • + <a href="#installation">Installation</a> • + <a href="#customization">Customization</a> • + <a href="#project-goals-and-alternatives">Project goals, alternatives</a><br> + [English] + [<a href="doc/README-zh.md">中文</a>] + [<a href="doc/README-ja.md">日本語</a>] + [<a href="doc/README-ko.md">한국어</a>] + [<a href="doc/README-ru.md">Русский</a>] +</p> + +### Sponsors + +A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br> +<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=bat&utm_source=github"> + <img src="doc/sponsors/workos-logo-white-bg.svg" width="200" alt="WorkOS"> + <br> + <strong>Your app, enterprise-ready.</strong> + <br> + <sub>Start selling to enterprise customers with just a few lines of code.</sub> + <br> + <sup>Add Single Sign-On (and more) in minutes instead of months.</sup> +</a> + +### Syntax highlighting + +`bat` supports syntax highlighting for a large number of programming and markup +languages: + +![Syntax highlighting example](https://imgur.com/rGsdnDe.png) + +### Git integration + +`bat` communicates with `git` to show modifications with respect to the index +(see left side bar): + +![Git integration example](https://i.imgur.com/2lSW4RE.png) + +### Show non-printable characters + +You can use the `-A`/`--show-all` option to show and highlight non-printable +characters: + +![Non-printable character example](https://i.imgur.com/WndGp9H.png) + +### Automatic paging + +By default, `bat` pipes its own output to a pager (e.g. `less`) if the output is too large for one screen. +If you would rather `bat` work like `cat` all the time (never page output), you can set `--paging=never` as an option, either on the command line or in your configuration file. +If you intend to alias `cat` to `bat` in your shell configuration, you can use `alias cat='bat --paging=never'` to preserve the default behavior. + +#### File concatenation + +Even with a pager set, you can still use `bat` to concatenate files :wink:. +Whenever `bat` detects a non-interactive terminal (i.e. when you pipe into another process or into a file), `bat` will act as a drop-in replacement for `cat` and fall back to printing the plain file contents, regardless of the `--pager` option's value. + +## How to use + +Display a single file on the terminal + +```bash +> bat README.md +``` + +Display multiple files at once + +```bash +> bat src/*.rs +``` + +Read from stdin, determine the syntax automatically (note, highlighting will +only work if the syntax can be determined from the first line of the file, +usually through a shebang such as `#!/bin/sh`) + +```bash +> curl -s https://sh.rustup.rs | bat +``` + +Read from stdin, specify the language explicitly + +```bash +> yaml2json .travis.yml | json_pp | bat -l json +``` + +Show and highlight non-printable characters: +```bash +> bat -A /etc/hosts +``` + +Use it as a `cat` replacement: + +```bash +bat > note.md # quickly create a new file + +bat header.md content.md footer.md > document.md + +bat -n main.rs # show line numbers (only) + +bat f - g # output 'f', then stdin, then 'g'. +``` + +### Integration with other tools + +#### `fzf` + +You can use `bat` as a previewer for [`fzf`](https://github.com/junegunn/fzf). To do this, +use `bat`s `--color=always` option to force colorized output. You can also use `--line-range` +option to restrict the load times for long files: + +```bash +fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}' +``` + +For more information, see [`fzf`'s `README`](https://github.com/junegunn/fzf#preview-window). + +#### `find` or `fd` + +You can use the `-exec` option of `find` to preview all search results with `bat`: + +```bash +find … -exec bat {} + +``` + +If you happen to use [`fd`](https://github.com/sharkdp/fd), you can use the `-X`/`--exec-batch` option to do the same: + +```bash +fd … -X bat +``` + +#### `ripgrep` + +With [`batgrep`](https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md), `bat` can be used as the printer for [`ripgrep`](https://github.com/BurntSushi/ripgrep) search results. + +```bash +batgrep needle src/ +``` + +#### `tail -f` + +`bat` can be combined with `tail -f` to continuously monitor a given file with syntax highlighting. + +```bash +tail -f /var/log/pacman.log | bat --paging=never -l log +``` + +Note that we have to switch off paging in order for this to work. We have also specified the syntax +explicitly (`-l log`), as it can not be auto-detected in this case. + +#### `git` + +You can combine `bat` with `git show` to view an older version of a given file with proper syntax +highlighting: + +```bash +git show v0.6.0:src/main.rs | bat -l rs +``` + +#### `git diff` + +You can combine `bat` with `git diff` to view lines around code changes with proper syntax +highlighting: +```bash +batdiff() { + git diff --name-only --relative --diff-filter=d | xargs 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 are looking for more support for git and diff operations, check out [`delta`](https://github.com/dandavison/delta). + +#### `xclip` + +The line numbers and Git modification markers in the output of `bat` can make it hard to copy +the contents of a file. To prevent this, you can call `bat` with the `-p`/`--plain` option or +simply pipe the output into `xclip`: +```bash +bat main.cpp | xclip +``` +`bat` will detect that the output is being redirected and print the plain file contents. + +#### `man` + +`bat` can be used as a colorizing pager for `man`, by setting the +`MANPAGER` environment variable: + +```bash +export MANPAGER="sh -c 'col -bx | bat -l man -p'" +man 2 select +``` +(replace `bat` with `batcat` if you are on Debian or Ubuntu) + +It might also be necessary to set `MANROFFOPT="-c"` if you experience +formatting problems. + +If you prefer to have this bundled in a new command, you can also use [`batman`](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md). + +Note that the [Manpage syntax](assets/syntaxes/02_Extra/Manpage.sublime-syntax) is developed in this repository and still needs some work. + +Also, note that this will [not work](https://github.com/sharkdp/bat/issues/1145) with Mandocs `man` implementation. + +#### `prettier` / `shfmt` / `rustfmt` + +The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) script is a wrapper that will format code and print it with `bat`. + +#### Highlighting `--help` messages + +You can use `bat` to colorize help text: `$ cp --help | bat -plhelp` + +You can also use a wrapper around this: + +```bash +# in your .bashrc/.zshrc/*rc +alias bathelp='bat --plain --language=help' +help() { + "$@" --help 2>&1 | bathelp +} +``` + +Then you can do `$ help cp` or `$ help git commit`. + +Please report any issues with the help syntax in [this repository](https://github.com/victor-gp/cmd-help-sublime-syntax). + + +## Installation + +[![Packaging status](https://repology.org/badge/vertical-allrepos/bat-cat.svg)](https://repology.org/project/bat-cat/versions) + +### On Ubuntu (using `apt`) +*... and other Debian-based Linux distributions.* + +`bat` is available on [Ubuntu since 20.04 ("Focal")](https://packages.ubuntu.com/search?keywords=bat&exact=1) and [Debian since August 2021 (Debian 11 - "Bullseye")](https://packages.debian.org/bullseye/bat). + +If your Ubuntu/Debian installation is new enough you can simply run: + +```bash +sudo apt install bat +``` + +**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name +clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions: +``` bash +mkdir -p ~/.local/bin +ln -s /usr/bin/batcat ~/.local/bin/bat +``` + +### On Ubuntu (using most recent `.deb` packages) +*... and other Debian-based Linux distributions.* + +If the package has not yet been promoted to your Ubuntu/Debian installation, or you want +the most recent release of `bat`, download the latest `.deb` package from the +[release page](https://github.com/sharkdp/bat/releases) and install it via: + +```bash +sudo dpkg -i bat_0.18.3_amd64.deb # adapt version number and architecture +``` + +### On Alpine Linux + +You can install [the `bat` package](https://pkgs.alpinelinux.org/packages?name=bat) +from the official sources, provided you have the appropriate repository enabled: + +```bash +apk add bat +``` + +### On Arch Linux + +You can install [the `bat` package](https://www.archlinux.org/packages/community/x86_64/bat/) +from the official sources: + +```bash +pacman -S bat +``` + +### On Fedora + +You can install [the `bat` package](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506) from the official [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository. + +```bash +dnf install bat +``` + +### On Funtoo Linux + +You can install [the `bat` package](https://github.com/funtoo/dev-kit/tree/1.4-release/sys-apps/bat) from dev-kit. + +```bash +emerge sys-apps/bat +``` + +### On Gentoo Linux + +You can install [the `bat` package](https://packages.gentoo.org/packages/sys-apps/bat) +from the official sources: + +```bash +emerge sys-apps/bat +``` + +### On Void Linux + +You can install `bat` via xbps-install: +```bash +xbps-install -S bat +``` + +### On Termux + +You can install `bat` via pkg: +```bash +pkg install bat +``` + +### On FreeBSD + +You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg: + +```bash +pkg install bat +``` + +or build it on your own from the FreeBSD ports: + +```bash +cd /usr/ports/textproc/bat +make install +``` + +### On OpenBSD + +You can install `bat` package using [`pkg_add(1)`](https://man.openbsd.org/pkg_add.1): + +```bash +pkg_add bat +``` + +### Via nix + +You can install `bat` using the [nix package manager](https://nixos.org/nix): + +```bash +nix-env -i bat +``` + +### On openSUSE + +You can install `bat` with zypper: + +```bash +zypper install bat +``` + +### Via snap package + +There is currently no recommended snap package available. +Existing packages may be available, but are not officially supported and may contain [issues](https://github.com/sharkdp/bat/issues/1519). + +### On macOS (or Linux) via Homebrew + +You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat): + +```bash +brew install bat +``` + +### On macOS via MacPorts + +Or install `bat` with [MacPorts](https://ports.macports.org/port/bat/summary): + +```bash +port install bat +``` + +### On Windows + +There are a few options to install `bat` on Windows. Once you have installed `bat`, +take a look at the ["Using `bat` on Windows"](#using-bat-on-windows) section. + +#### Prerequisites + +You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package. + +#### With Chocolatey + +You can install `bat` via [Chocolatey](https://chocolatey.org/packages/Bat): +```bash +choco install bat +``` + +#### With Scoop + +You can install `bat` via [scoop](https://scoop.sh/): +```bash +scoop install bat +``` + +#### From prebuilt binaries: + +You can download prebuilt binaries from the [Release page](https://github.com/sharkdp/bat/releases), + +You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package. + +### From binaries + +Check out the [Release page](https://github.com/sharkdp/bat/releases) for +prebuilt versions of `bat` for many different architectures. Statically-linked +binaries are also available: look for archives with `musl` in the file name. + +### From source + +If you want to build `bat` from source, you need Rust 1.60.0 or +higher. You can then use `cargo` to build everything: + +```bash +cargo install --locked bat +``` + +Note that additional files like the man page or shell completion +files can not be installed in this way. They will be generated by `cargo` and should be available in the cargo target folder (under `build`). + +## Customization + +### Highlighting theme + +Use `bat --list-themes` to get a list of all available themes for syntax +highlighting. To select the `TwoDark` theme, call `bat` with the +`--theme=TwoDark` option or set the `BAT_THEME` environment variable to +`TwoDark`. Use `export BAT_THEME="TwoDark"` in your shell's startup file to +make the change permanent. Alternatively, use `bat`s +[configuration file](https://github.com/sharkdp/bat#configuration-file). + +If you want to preview the different themes on a custom file, you can use +the following command (you need [`fzf`](https://github.com/junegunn/fzf) for this): +```bash +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. +You can also use a custom theme by following the +['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes). + +### 8-bit themes + +`bat` has three themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors), +even when truecolor support is available: + +- `ansi` looks decent on any terminal. It uses 3-bit colors: black, red, green, + yellow, blue, magenta, cyan, and white. +- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses + 4-bit colors (3-bit colors plus bright variants) in accordance with the + [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md). +- `base16-256` is designed for [base16-shell](https://github.com/chriskempson/base16-shell). + It replaces certain bright colors with 8-bit colors from 16 to 21. **Do not** use this simply + because you have a 256-color terminal but are not using base16-shell. + +Although these themes are more restricted, they have three advantages over truecolor themes. They: + +- Enjoy maximum compatibility. Some terminal utilities do not support more than 3-bit colors. +- Adapt to terminal theme changes. Even for already printed output. +- Visually harmonize better with other terminal software. + +### Output style + +You can use the `--style` option to control the appearance of `bat`s output. +You can use `--style=numbers,changes`, for example, to show only Git changes +and line numbers but no grid and no file header. Set the `BAT_STYLE` environment +variable to make these changes permanent or use `bat`s +[configuration file](https://github.com/sharkdp/bat#configuration-file). + +### Adding new syntaxes / language definitions + +Should you find that a particular syntax is not available within `bat`, you can follow these +instructions to easily add new syntaxes to your current `bat` installation. + +`bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/) +library for syntax highlighting. `syntect` can read any +[Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html) +and theme. + +A good resource for finding Sublime Syntax packages is [Package Control](https://packagecontrol.io/). Once you found a +syntax: + +1. Create a folder with syntax definition files: + + ```bash + mkdir -p "$(bat --config-dir)/syntaxes" + cd "$(bat --config-dir)/syntaxes" + + # Put new '.sublime-syntax' language definition files + # in this folder (or its subdirectories), for example: + git clone https://github.com/tellnobody1/sublime-purescript-syntax + ``` + +2. Now use the following command to parse these files into a binary cache: + + ```bash + bat cache --build + ``` + +3. Finally, use `bat --list-languages` to check if the new languages are available. + + If you ever want to go back to the default settings, call: + + ```bash + bat cache --clear + ``` + +4. If you think that a specific syntax should be included in `bat` by default, please + consider opening a "syntax request" ticket after reading the policies and + instructions [here](doc/assets.md): [Open Syntax Request](https://github.com/sharkdp/bat/issues/new?labels=syntax-request&template=syntax_request.md). + +### Adding new themes + +This works very similar to how we add new syntax definitions. + +First, create a folder with the new syntax highlighting themes: +```bash +mkdir -p "$(bat --config-dir)/themes" +cd "$(bat --config-dir)/themes" + +# Download a theme in '.tmTheme' format, for example: +git clone https://github.com/greggb/sublime-snazzy + +# Update the binary cache +bat cache --build +``` + +Finally, use `bat --list-themes` to check if the new themes are available. + +### Adding or changing file type associations + +You can add new (or change existing) file name patterns using the `--map-syntax` +command line option. The option takes an argument of the form `pattern:syntax` where +`pattern` is a glob pattern that is matched against the file name and +the absolute file path. The `syntax` part is the full name of a supported language +(use `bat --list-languages` for an overview). + +**Note:** You probably want to use this option as [an entry in `bat`'s configuration file](#configuration-file) +for persistence instead of passing it on the command line as a one-off. Generally +you'd just use `-l` if you want to manually specify a language for a file. + +Example: To use "INI" syntax highlighting for all files with a `.conf` file extension, use +```bash +--map-syntax='*.conf:INI' +``` + +Example: To open all files called `.ignore` (exact match) with the "Git Ignore" syntax, use: +```bash +--map-syntax='.ignore:Git Ignore' +``` + +Example: To open all `.conf` files in subfolders of `/etc/apache2` with the "Apache Conf" +syntax, use (this mapping is already built in): +```bash +--map-syntax='/etc/apache2/**/*.conf:Apache Conf' +``` + +### Using a different pager + +`bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not +set, `less` is used by default. If you want to use a different pager, you can either modify the +`PAGER` variable or set the `BAT_PAGER` environment variable to override what is specified in +`PAGER`. + +**Note**: If `PAGER` is `more` or `most`, `bat` will silently use `less` instead to ensure support for colors. + +If you want to pass command-line arguments to the pager, you can also set them via the +`PAGER`/`BAT_PAGER` variables: + +```bash +export BAT_PAGER="less -RF" +``` + +Instead of using environment variables, you can also use `bat`s [configuration file](https://github.com/sharkdp/bat#configuration-file) to configure the pager (`--pager` option). + +**Note**: By default, if the pager is set to `less` (and no command-line options are specified), +`bat` will pass the following command line options to the pager: `-R`/`--RAW-CONTROL-CHARS`, +`-F`/`--quit-if-one-screen` and `-X`/`--no-init`. The last option (`-X`) is only used for `less` +versions older than 530. + +The `-R` option is needed to interpret ANSI colors correctly. The second option (`-F`) instructs +less to exit immediately if the output size is smaller than the vertical size of the terminal. +This is convenient for small files because you do not have to press `q` to quit the pager. The +third option (`-X`) is needed to fix a bug with the `--quit-if-one-screen` feature in old versions +of `less`. Unfortunately, it also breaks mouse-wheel support in `less`. + +If you want to enable mouse-wheel scrolling on older versions of `less`, you can pass just `-R` (as +in the example above, this will disable the quit-if-one-screen feature). For less 530 or newer, +it should work out of the box. + +### Indentation + +`bat` expands tabs to 4 spaces by itself, not relying on the pager. To change this, simply add the +`--tabs` argument with the number of spaces you want to be displayed. + +**Note**: Defining tab stops for the pager (via the `--pager` argument by `bat`, or via the `LESS` +environment variable for `less`) won't be taken into account because the pager will already get +expanded spaces instead of tabs. This behaviour is added to avoid indentation issues caused by the +sidebar. Calling `bat` with `--tabs=0` will override it and let tabs be consumed by the pager. + +### Dark mode + +If you make use of the dark mode feature in macOS, you might want to configure `bat` to use a different +theme based on the OS theme. The following snippet uses the `default` theme when in the _dark mode_ +and the `GitHub` theme when in the _light mode_. + +```bash +alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)" +``` + + +## Configuration file + +`bat` can also be customized with a configuration file. The location of the file is dependent +on your operating system. To get the default path for your system, call +```bash +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: +```bash +export BAT_CONFIG_PATH="/path/to/bat.conf" +``` + +A default configuration file can be created with the `--generate-config-file` option. +```bash +bat --generate-config-file +``` + +There is also now a systemwide configuration file, which is located under `/etc/bat/config` on +Linux and Mac OS and `C:\ProgramData\bat\config` on windows. If the system wide configuration +file is present, the content of the user configuration will simply be appended to it. + +### Format + +The configuration file is a simple list of command line arguments. Use `bat --help` to see a full list of possible options and values. In addition, you can add comments by prepending a line with the `#` character. + +Example configuration file: +```bash +# Set the theme to "TwoDark" +--theme="TwoDark" + +# Show line numbers, Git modifications and file header (but no grid) +--style="numbers,changes,header" + +# Use italic text on the terminal (not supported on all terminals) +--italic-text=always + +# Use C++ syntax for Arduino .ino files +--map-syntax "*.ino:C++" +``` + +## Using `bat` on Windows + +`bat` mostly works out-of-the-box on Windows, but a few features may need extra configuration. + +### Prerequisites + +You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package. + +### Paging + +Windows only includes a very limited pager in the form of `more`. You can download a Windows binary +for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through +Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in +your `PATH` or [define an environment variable](#using-a-different-pager). The [Chocolatey package](#on-windows) installs `less` automatically. + +### Colors + +Windows 10 natively supports colors in both `conhost.exe` (Command Prompt) and PowerShell since +[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as +well as in newer versions of bash. On earlier versions of Windows, you can use +[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/). + +**Note:** The Git and MSYS versions of `less` do not correctly interpret colors on Windows. If you +don’t have any other pagers installed, you can disable paging entirely by passing `--paging=never` +or by setting `BAT_PAGER` to an empty string. + +### Cygwin + +`bat` on Windows does not natively support Cygwin's unix-style paths (`/cygdrive/*`). When passed an absolute cygwin path as an argument, `bat` will encounter the following error: `The system cannot find the path specified. (os error 3)` + +This can be solved by creating a wrapper or adding the following function to your `.bash_profile` file: + +```bash +bat() { + local index + local args=("$@") + for index in $(seq 0 ${#args[@]}) ; do + case "${args[index]}" in + -*) continue;; + *) [ -e "${args[index]}" ] && args[index]="$(cygpath --windows "${args[index]}")";; + esac + done + command bat "${args[@]}" +} +``` + +## Troubleshooting + +### Garbled output + +If an input file contains color codes or other ANSI escape sequences or control characters, `bat` will have problems +performing syntax highlighting and text wrapping, and thus the output can become garbled. +When displaying such files it is recommended to disable both syntax highlighting and wrapping by +passing the `--color=never --wrap=never` options to `bat`. + +### Terminals & colors + +`bat` handles terminals *with* and *without* truecolor support. However, the colors in most syntax +highlighting themes are not optimized for 8-bit colors. It is therefore strongly recommended +that you use a terminal with 24-bit truecolor support (`terminator`, `konsole`, `iTerm2`, ...), +or use one of the basic [8-bit themes](#8-bit-themes) designed for a restricted set of colors. +See [this article](https://gist.github.com/XVilka/8346728) for more details and a full list of +terminals with truecolor support. + +Make sure that your truecolor terminal sets the `COLORTERM` variable to either `truecolor` or +`24bit`. Otherwise, `bat` will not be able to determine whether or not 24-bit escape sequences +are supported (and fall back to 8-bit colors). + +### Line numbers and grid are hardly visible + +Please try a different theme (see `bat --list-themes` for a list). The `OneHalfDark` and +`OneHalfLight` themes provide grid and line colors that are brighter. + +### File encodings + +`bat` natively supports UTF-8 as well as UTF-16. For every other file encoding, you may need to +convert to UTF-8 first because the encodings can typically not be auto-detected. You can `iconv` +to do so. +Example: if you have a PHP file in Latin-1 (ISO-8859-1) encoding, you can call: +``` bash +iconv -f ISO-8859-1 -t UTF-8 my-file.php | bat +``` +Note: you might have to use the `-l`/`--language` option if the syntax can not be auto-detected +by `bat`. + +## Development + +```bash +# Recursive clone to retrieve all submodules +git clone --recursive https://github.com/sharkdp/bat + +# Build (debug version) +cd bat +cargo build --bins + +# Run unit tests and integration tests +cargo test + +# Install (release version) +cargo install --path . --locked + +# Build a bat binary with modified syntaxes and themes +bash assets/create.sh +cargo install --path . --locked --force +``` + +If you want to build an application that uses `bat`s pretty-printing +features as a library, check out the [the API documentation](https://docs.rs/bat/). +Note that you have to use either `regex-onig` or `regex-fancy` as a feature +when you depend on `bat` as a library. + +## Contributing + +Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide. + +## Maintainers + +- [sharkdp](https://github.com/sharkdp) +- [eth-p](https://github.com/eth-p) +- [keith-hall](https://github.com/keith-hall) +- [Enselic](https://github.com/Enselic) + +## Security vulnerabilities + +Please contact [David Peter](https://david-peter.de/) via email if you want to report a vulnerability in `bat`. + +## Project goals and alternatives + +`bat` tries to achieve the following goals: + +- Provide beautiful, advanced syntax highlighting +- Integrate with Git to show file modifications +- Be a drop-in replacement for (POSIX) `cat` +- Offer a user-friendly command-line interface + +There are a lot of alternatives, if you are looking for similar programs. See +[this document](doc/alternatives.md) for a comparison. + +## License +Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat). + +`bat` is made available under the terms of either the MIT License or the Apache License 2.0, at your option. + +See the [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) files for license details. diff --git a/bat/autocomplete/_bat.ps1 b/bat/autocomplete/_bat.ps1 new file mode 100644 index 0000000..6cac09b --- /dev/null +++ b/bat/autocomplete/_bat.ps1 @@ -0,0 +1,92 @@ + +using namespace System.Management.Automation +using namespace System.Management.Automation.Language + +Register-ArgumentCompleter -Native -CommandName 'bat' -ScriptBlock { + param($wordToComplete, $commandAst, $cursorPosition) + + $commandElements = $commandAst.CommandElements + $command = @( + 'bat' + for ($i = 1; $i -lt $commandElements.Count; $i++) { + $element = $commandElements[$i] + if ($element -isnot [StringConstantExpressionAst] -or + $element.StringConstantType -ne [StringConstantType]::BareWord -or + $element.Value.StartsWith('-')) { + break + } + $element.Value + }) -join ';' + + $completions = @(switch ($command) { + 'bat' { + [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('--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('--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.') + [CompletionResult]::new('cache', 'cache', [CompletionResultType]::ParameterValue, 'Modify the syntax-definition and theme cache') + break + } + 'bat;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') + break + } + }) + + $completions.Where{ $_.CompletionText -like "$wordToComplete*" } | + Sort-Object -Property ListItemText +} diff --git a/bat/autocomplete/bat.bash b/bat/autocomplete/bat.bash new file mode 100644 index 0000000..77c2aad --- /dev/null +++ b/bat/autocomplete/bat.bash @@ -0,0 +1,101 @@ +# shellcheck disable=SC2207 + +# Requires https://github.com/scop/bash-completion + +# Macs have bash3 for which the bash-completion package doesn't include +# _init_completion. This is a minimal version of that function. +__bat_init_completion() +{ + COMPREPLY=() + _get_comp_words_by_ref "$@" cur prev words cword +} + +_bat() { + local cur prev words cword split=false + if declare -F _init_completion >/dev/null 2>&1; then + _init_completion -s || return 0 + else + __bat_init_completion -n "=" || return 0 + _split_longopt && split=true + fi + + if [[ ${words[1]-} == cache ]]; then + case $prev in + --source | --target) + _filedir -d + return 0 + ;; + esac + COMPREPLY=($(compgen -W " + --build --clear --source --target --blank --help + " -- "$cur")) + return 0 + fi + + case $prev in + -l | --language) + local IFS=$'\n' + COMPREPLY=($(compgen -W "$( + "$1" --list-languages | while IFS=: read -r lang _; do + printf "%s\n" "$lang" + done + )" -- "$cur")) + compopt -o filenames # for escaping + return 0 + ;; + -H | --highlight-line | --diff-context | --tabs | --terminal-width | \ + -m | --map-syntax | --style | --line-range | -h | --help | -V | \ + --version | --diagnostic | --config-file | --config-dir | \ + --cache-dir | --generate-config-file) + # argument required but no completion available, or option + # causes an exit + return 0 + ;; + --file-name) + _filedir + return 0 + ;; + --wrap) + COMPREPLY=($(compgen -W "auto never character" -- "$cur")) + return 0 + ;; + --color | --decorations | --paging) + COMPREPLY=($(compgen -W "auto never always" -- "$cur")) + return 0 + ;; + --italic-text) + COMPREPLY=($(compgen -W "always never" -- "$cur")) + return 0 + ;; + --pager) + COMPREPLY=($(compgen -c -- "$cur")) + return 0 + ;; + --theme) + local IFS=$'\n' + COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur")) + compopt -o filenames # for escaping + return 0 + ;; + esac + + $split && return 0 + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W " + --show-all --plain --language --highlight-line + --file-name --diff --diff-context --tabs --wrap + --terminal-width --number --color --italic-text + --decorations --paging --pager --map-syntax --theme + --list-themes --style --line-range --list-languages + --help --version --force-colorization --unbuffered + --diagnostic --config-file --config-dir --cache-dir + --generate-config-file + " -- "$cur")) + return 0 + fi + + _filedir + ((cword == 1)) && COMPREPLY+=($(compgen -W cache -- "$cur")) + +} && complete -F _bat bat diff --git a/bat/autocomplete/bat.fish b/bat/autocomplete/bat.fish new file mode 100644 index 0000000..61f6ea7 --- /dev/null +++ b/bat/autocomplete/bat.fish @@ -0,0 +1,219 @@ +# Fish Shell Completions +# Copy or symlink to $XDG_CONFIG_HOME/fish/completions/bat.fish +# ($XDG_CONFIG_HOME is usually set to ~/.config) + +# `bat` is `batcat` on Debian and Ubuntu +set bat bat + +# Helper functions: + +function __bat_complete_files -a token + # Cheat to complete files by calling `complete -C` on a fake command name, + # like `__fish_complete_directories` does. + set -l fake_command aaabccccdeeeeefffffffffgghhhhhhiiiii + complete -C"$fake_command $token" +end + +function __bat_complete_one_language -a comp + command $bat --list-languages | string split -f1 : | string match -e "$comp" +end + +function __bat_complete_list_languages + for spec in (command $bat --list-languages) + set -l name (string split -f1 : $spec) + for ext in (string split -f2 : $spec | string split ,) + test -n "$ext"; or continue + string match -rq '[/*]' $ext; and continue + printf "%s\t%s\n" $ext $name + end + printf "%s\t\n" $name + end +end + +function __bat_complete_map_syntax + set -l token (commandline -ct) + + if string match -qr '(?<glob>.+):(?<syntax>.*)' -- $token + # If token ends with a colon, complete with the list of language names. + set -f comps $glob:(__bat_complete_one_language $syntax) + else if string match -qr '\*' -- $token + # If token contains a globbing character (`*`), complete only possible + # globs in the current directory + set -f comps (__bat_complete_files $token | string match -er '[*]'): + else + # Complete files (and globs). + set -f comps (__bat_complete_files $token | string match -erv '/$'): + end + + if set -q comps[1] + printf "%s\t\n" $comps + end +end + +function __bat_cache_subcommand + __fish_seen_subcommand_from cache +end + +# Returns true if no exclusive arguments seen. +function __bat_no_excl_args + not __bat_cache_subcommand; and not __fish_seen_argument \ + -s h -l help \ + -s V -l version \ + -l acknowledgements \ + -l config-dir -l config-file \ + -l diagnostic \ + -l list-languages -l list-themes +end + +# Returns true if the 'cache' subcommand is seen without any exclusive arguments. +function __bat_cache_no_excl + __bat_cache_subcommand; and not __fish_seen_argument \ + -s h -l help \ + -l acknowledgements -l build -l clear +end + +function __bat_style_opts + set -l style_opts \ + "default,recommended components" \ + "auto,same as 'default' unless piped" \ + "full,all components" \ + "plain,no components" \ + "changes,Git change markers" \ + "header,alias for header-filename" \ + "header-filename,filename above content" \ + "header-filesize,filesize above content" \ + "grid,lines b/w sidebar/header/content" \ + "numbers,line numbers in sidebar" \ + "rule,separate files" \ + "snip,separate ranges" + + string replace , \t $style_opts +end + +# Use option argument descriptions to indicate which is the default, saving +# horizontal space and making sure the option description isn't truncated. +set -l color_opts ' + auto\tdefault + never\t + always\t +' +set -l decorations_opts $color_opts +set -l paging_opts $color_opts + +# Include some examples so we can indicate the default. +set -l pager_opts ' + less\tdefault + less\ -FR\t + more\t + vimpager\t +' + +set -l italic_text_opts ' + always\t + never\tdefault +' + +set -l wrap_opts ' + auto\tdefault + never\t + character\t +' + +# While --tabs theoretically takes any number, most people should be OK with these. +# Specifying a list lets us explain what 0 does. +set -l tabs_opts ' + 0\tpass\ tabs\ through\ directly + 1\t + 2\t + 4\t + 8\t +' + +# Completions: + +complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg + +complete -c $bat -l color -x -a "$color_opts" -d "When to use colored output" -n __bat_no_excl_args + +complete -c $bat -l config-dir -f -d "Display location of configuration directory" -n __fish_is_first_arg + +complete -c $bat -l config-file -f -d "Display location of configuration file" -n __fish_is_first_arg + +complete -c $bat -l decorations -x -a "$decorations_opts" -d "When to use --style decorations" -n __bat_no_excl_args + +complete -c $bat -l diagnostic -d "Print diagnostic info for bug reports" -n __fish_is_first_arg + +complete -c $bat -s d -l diff -d "Only show lines with Git changes" -n __bat_no_excl_args + +complete -c $bat -l diff-context -x -d "Show N context lines around Git changes" -n "__fish_seen_argument -s d -l diff" + +complete -c $bat -l file-name -x -d "Specify the display name" -n __bat_no_excl_args + +complete -c $bat -s f -l force-colorization -d "Force color and decorations" -n __bat_no_excl_args + +complete -c $bat -s h -d "Print a concise overview" -n __fish_is_first_arg + +complete -c $bat -l help -f -d "Print all help information" -n __fish_is_first_arg + +complete -c $bat -s H -l highlight-line -x -d "Highlight line(s) N[:M]" -n __bat_no_excl_args + +complete -c $bat -l ignored-suffix -x -d "Ignore extension" -n __bat_no_excl_args + +complete -c $bat -l italic-text -x -a "$italic_text_opts" -d "When to use italic text in the output" -n __bat_no_excl_args + +complete -c $bat -s l -l language -x -k -a "(__bat_complete_list_languages)" -d "Set the syntax highlighting language" -n __bat_no_excl_args + +complete -c $bat -s r -l line-range -x -d "Only print lines [M]:[N] (either optional)" -n __bat_no_excl_args + +complete -c $bat -l list-languages -f -d "List syntax highlighting languages" -n __fish_is_first_arg + +complete -c $bat -l list-themes -f -d "List syntax highlighting themes" -n __fish_is_first_arg + +complete -c $bat -s m -l map-syntax -x -a "(__bat_complete_map_syntax)" -d "Map <glob pattern>:<language syntax>" -n __bat_no_excl_args + +complete -c $bat -s n -l number -d "Only show line numbers, no other decorations" -n __bat_no_excl_args + +complete -c $bat -l pager -x -a "$pager_opts" -d "Which pager to use" -n __bat_no_excl_args + +complete -c $bat -l paging -x -a "$paging_opts" -d "When to use the pager" -n __bat_no_excl_args + +complete -c $bat -s p -l plain -d "Disable decorations" -n __bat_no_excl_args + +complete -c $bat -o pp -d "Disable decorations and paging" -n __bat_no_excl_args + +complete -c $bat -s P -d "Disable paging" -n __bat_no_excl_args + +complete -c $bat -s A -l show-all -d "Show non-printable characters" -n __bat_no_excl_args + +complete -c $bat -l style -x -k -a "(__fish_complete_list , __bat_style_opts)" -d "Specify which non-content elements to display" -n __bat_no_excl_args + +complete -c $bat -l tabs -x -a "$tabs_opts" -d "Set tab width" -n __bat_no_excl_args + +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 -s V -l version -f -d "Show version information" -n __fish_is_first_arg + +complete -c $bat -l wrap -x -a "$wrap_opts" -d "Text-wrapping mode" -n __bat_no_excl_args + +# Sub-command 'cache' completions +complete -c $bat -a cache -d "Modify the syntax/language definition cache" -n __fish_use_subcommand + +complete -c $bat -l build -f -d "Parse new definitions into cache" -n __bat_cache_no_excl + +complete -c $bat -l clear -f -d "Reset definitions to defaults" -n __bat_cache_no_excl + +complete -c $bat -l blank -f -d "Create new data instead of appending" -n "__bat_cache_subcommand; and not __fish_seen_argument -l clear" + +complete -c $bat -l source -x -a "(__fish_complete_directories)" -d "Load syntaxes and themes from DIR" -n "__bat_cache_subcommand; and not __fish_seen_argument -l clear" + +complete -c $bat -l target -x -a "(__fish_complete_directories)" -d "Store cache in DIR" -n __bat_cache_subcommand + +complete -c $bat -l acknowledgements -d "Build acknowledgements.bin" -n __bat_cache_no_excl + +complete -c $bat -s h -d "Print a concise overview of $bat-cache help" -n __bat_cache_no_excl + +complete -c $bat -l help -f -d "Print all $bat-cache help" -n __bat_cache_no_excl + +# vim:ft=fish diff --git a/bat/autocomplete/bat.zsh b/bat/autocomplete/bat.zsh new file mode 100644 index 0000000..b2c93cb --- /dev/null +++ b/bat/autocomplete/bat.zsh @@ -0,0 +1,99 @@ +#compdef bat + +local context state state_descr line +typeset -A opt_args + +(( $+functions[_bat_cache_subcommand] )) || +_bat_cache_subcommand() { + local -a args + args=( + '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]' + '(-b --build -c --clear)'{-c,--clear}'[Remove the cached syntax definitions and themes]' + '(--source)'--source='[Use a different directory to load syntaxes and themes from]:directory:_files -/' + '(--target)'--target='[Use a different directory to store the cached syntax and theme set]:directory:_files -/' + '(--blank)'--blank'[Create completely new syntax and theme sets]' + '(: -)'{-h,--help}'[Prints help information]' + '*: :' + ) + + _arguments -S -s $args +} + +(( $+functions[_bat_main] )) || +_bat_main() { + local -a args + args=( + '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' + '*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]' + '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language' + '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...' + '(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files' + '(-d --diff)'--diff'[Only show lines that have been added/removed/modified]' + '(--diff-context)'--diff-context'[Include N lines of context around added/removed/modified lines when using `--diff`]:<N> (lines):()' + '(--tabs)'--tabs'[Set the tab width to T spaces]:<T> (tab width):()' + '(--wrap)'--wrap='[Specify the text-wrapping mode]:<when>:(auto never character)' + '(--terminal-width)'--terminal-width'[Explicitly set the width of the terminal instead of determining it automatically]:<width>' + '(-n --number)'{-n,--number}'[Show line numbers]' + '(--color)'--color='[When to use colors]:<when>:(auto never always)' + '(--italic-text)'--italic-text='[Use italics in output]:<when>:(always never)' + '(--decorations)'--decorations='[When to show the decorations]:<when>:(auto never always)' + '(--paging)'--paging='[Specify when to use the pager]:<when>:(auto never always)' + '(-m --map-syntax)'{-m+,--map-syntax=}'[Use the specified syntax for files matching the glob pattern]:<glob\:syntax>...' + '(--theme)'--theme='[Set the color theme for syntax highlighting]:<theme>:->theme' + '(: --list-themes --list-languages -L)'--list-themes'[Display all supported highlighting themes]' + '(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style' + '(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N\:M>...' + '(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]' + '(: --no-config)'--no-config'[Do not use the configuration file]' + '(: --no-custom-assets)'--no-custom-assets'[Do not load custom assets]' + '(: --config-dir)'--config-dir'[Show bat'"'"'s configuration directory]' + '(: --config-file)'--config-file'[Show path to the configuration file]' + '(: --generate-config-file)'--generate-config-file'[Generates a default configuration file]' + '(: --cache-dir)'--cache-dir'[Show bat'"'"'s cache directory]' + '(: -)'{-h,--help}'[Print this help message]' + '(: -)'{-V,--version}'[Show version information]' + '*: :_files' + ) + + _arguments -S -s $args + + case "$state" in + language) + local IFS=$'\n' + local -a languages + languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') ) + + _describe 'language' languages + ;; + + theme) + local IFS=$'\n' + local -a themes + themes=( $(bat --list-themes | sort) ) + + _values 'theme' $themes + ;; + + style) + _values -s , 'style' default auto full plain changes header header-filename header-filesize grid rule numbers snip + ;; + esac +} + +# first positional argument +if (( ${#words} == 2 )); then + local -a subcommands + subcommands=('cache:Modify the syntax-definition and theme cache') + _describe subcommand subcommands + _bat_main +else + case $words[2] in + cache) + _bat_cache_subcommand + ;; + + *) + _bat_main + ;; + esac +fi diff --git a/bat/bat.1 b/bat/bat.1 new file mode 100644 index 0000000..7c939ad --- /dev/null +++ b/bat/bat.1 @@ -0,0 +1,238 @@ +.TH BAT "1" +.SH NAME +bat \- a cat(1) clone with syntax highlighting and Git integration. +.SH "USAGE" +.IP "bat [OPTIONS] [FILE]..." +.IP "bat cache [CACHE-OPTIONS] [--build|--clear] +.SH DESCRIPTION +bat prints the syntax-highlighted content of a collection of FILEs to the +terminal. If no FILE is specified, or when FILE is '-', it reads from standard input. + +bat supports a large number of programming and markup languages. +It also communicates with git(1) to show modifications with respect to the git index. +bat automatically pipes its output through a pager (by default: less). + +Whenever the output of bat goes to a non-interactive terminal, i.e. when the +output is piped into another process or into a file, bat will act as a drop-in +replacement for cat(1) and fall back to printing the plain file contents. + +.SH "OPTIONS" +General remarks: Command-line options like '-l'/'--language' that take values can be specified as +either '--language value', '--language=value', '-l value' or '-lvalue'. +.HP +\fB\-A\fR, \fB\-\-show\-all\fR +.IP +Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to +control the width of the tab\-placeholders. +.HP +\fB\-p\fR, \fB\-\-plain\fR +.IP +Only show plain style, no decorations. This is an alias for +\&'\-\-style=plain'. When '\-p' is used twice ('\-pp'), it also disables +automatic paging (alias for '\-\-style=plain \fB\-\-paging\fR=\fI\,never\/\fR'). +.HP +\fB\-l\fR, \fB\-\-language\fR <language> +.IP +Explicitly set the language for syntax highlighting. The language can be +specified as a name (like 'C++' or 'LaTeX') or possible file extension +(like 'cpp', 'hpp' or 'md'). Use '\-\-list\-languages' to show all supported +language names and file extensions. +.HP +\fB\-H\fR, \fB\-\-highlight\-line\fR <N:M>... +.IP +Highlight the specified line ranges with a different background color. For example: +.RS +.IP "\-\-highlight\-line 40" +highlights line 40 +.IP "\-\-highlight\-line 30:40" +highlights lines 30 to 40 +.IP "\-\-highlight\-line :40" +highlights lines 1 to 40 +.IP "\-\-highlight\-line 40:" +highlights lines 40 to the end of the file +.IP "\-\-highlight\-line 30:+10" +highlights lines 30 to 40 +.RE +.HP +\fB\-\-file\-name\fR <name>... +.IP +Specify the name to display for a file. Useful when piping data to bat from STDIN when bat does not otherwise know the filename. Note that the provided file name is also used for syntax detection. +.HP +\fB\-d\fR, \fB\-\-diff\fR +.IP +Only show lines that have been added/removed/modified with respect to the Git index. Use '\-\-diff\-context=N' to control how much context you want to see. +.HP +\fB\-\-diff\-context\fR <N>... +.IP +Include N lines of context around added/removed/modified lines when using '\-\-diff'. +.HP +\fB\-\-tabs\fR <T> +.IP +Set the tab width to T spaces. Use a width of 0 to pass tabs through directly +.HP +\fB\-\-wrap\fR <mode> +.IP +Specify the text\-wrapping mode (*auto*, never, character). The '\-\-terminal\-width' option +can be used in addition to control the output width. +.HP +\fB\-\-terminal\-width\fR <width> +.IP +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'. +.HP +\fB\-n\fR, \fB\-\-number\fR +.IP +Only show line numbers, no other decorations. This is an alias for '\-\-style=numbers' +.HP +\fB\-\-color\fR <when> +.IP +Specify when to use colored output. The automatic mode only enables colors if an +interactive terminal is detected. Possible values: *auto*, never, always. +.HP +\fB\-\-italic\-text\fR <when> +.IP +Specify when to use ANSI sequences for italic text in the output. Possible values: +always, *never*. +.HP +\fB\-\-decorations\fR <when> +.IP +Specify when to use the decorations that have been specified via '\-\-style'. The +automatic mode only enables decorations if an interactive terminal is detected. Possible +values: *auto*, never, always. +.HP +\fB\-f\fR, \fB\-\-force\-colorization\fR +.IP +Alias for '--decorations=always --color=always'. This is useful \ +if the output of bat is piped to another program, but you want \ +to keep the colorization/decorations. +.HP +\fB\-\-paging\fR <when> +.IP +Specify when to use the pager. To disable the pager, use \&'\-\-paging=never' or its alias, +\fB-P\fR. To disable the pager permanently, set BAT_PAGER to an empty string. To control +which pager is used, see the '\-\-pager' option. Possible values: *auto*, never, always. +.HP +\fB\-\-pager\fR <command> +.IP +Determine which pager is used. This option will override the PAGER and BAT_PAGER +environment variables. The default pager is 'less'. To control when the pager is used, see +the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'. + +Note: By default, if the pager is set to 'less' (and no command-line options are specified), 'bat' will pass the following command line options to the pager: '-R'/'--RAW-CONTROL-CHARS', '-F'/'--quit-if-one-screen' and '-X'/'--no-init'. The last option ('-X') is only used for 'less' versions older than 530. The '-R' option is needed to interpret ANSI colors correctly. The second option ('-F') instructs less to exit immediately if the output size is smaller than the vertical size of the terminal. This is convenient for small files because you do not have to press 'q' to quit the pager. The third option ('-X') is needed to fix a bug with the '--quit-if-one-screen' feature in old versions of 'less'. Unfortunately, it also breaks mouse-wheel support in 'less'. If you want to enable mouse-wheel scrolling on older versions of 'less', you can pass just '-R' (as in the example above, this will disable the quit-if-one-screen feature). For less 530 or newer, it should work out of the box. +.HP +\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>... +.IP +Map a glob pattern to an existing syntax name. The glob pattern is matched on the full +path and the filename. For example, to highlight *.build files with the Python syntax, +use -m '*.build:Python'. To highlight files named '.myignore' with the Git Ignore +syntax, use -m '.myignore:Git Ignore'. +Note that the right-hand side is the *name* of the syntax, not a file extension. +.HP +\fB\-\-theme\fR <theme> +.IP +Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes. +To set a default theme, add the '\-\-theme="..."' option to the configuration file or +export the BAT_THEME environment variable (e.g.: export BAT_THEME="..."). +.HP +\fB\-\-list\-themes\fR +.IP +Display a list of supported themes for syntax highlighting. +.HP +\fB\-\-style\fR <style\-components> +.IP +Configure which elements (line numbers, file headers, grid borders, Git modifications, +\&..) to display in addition to the file contents. The argument is a comma\-separated list +of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full'). +To set a default style, add the '\-\-style=".."' option to the configuration file or +export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible +values: *default*, full, auto, plain, changes, header, header-filename, header-filesize, grid, +rule, numbers, snip. +.HP +\fB\-r\fR, \fB\-\-line\-range\fR <N:M>... +.IP +Only print the specified range of lines for each file. For example: +.RS +.IP "\-\-line\-range 30:40" +prints lines 30 to 40 +.IP "\-\-line\-range :40" +prints lines 1 to 40 +.IP "\-\-line\-range 40:" +prints lines 40 to the end of the file +.IP "\-\-line\-range 30:+10" +prints lines 30 to 40 +.RE +.HP +\fB\-L\fR, \fB\-\-list\-languages\fR +.IP +Display a list of supported languages for syntax highlighting. +.HP +\fB\-u\fR, \fB\-\-unbuffered\fR +.IP +This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is +always unbuffered \- this option is simply ignored. +.HP +\fB\-h\fR, \fB\-\-help\fR +.IP +Print this help message. +.HP +\fB\-V\fR, \fB\-\-version\fR +.IP +Show version information. +.SH "POSITIONAL ARGUMENTS" +.HP +\fB<FILE>...\fR +.IP +Files to print and concatenate. Use a dash ('\-') or no argument at all to read from +standard input. +.SH "SUBCOMMANDS" +.HP +\fBcache\fR - Modify the syntax\-definition and theme cache. +.SH "FILES" +bat can also be customized with a configuration file. The location of the file +is dependent on your operating system. To get the default path for your system, call: + +\fBbat --config-file\fR + +Alternatively, you can use the BAT_CONFIG_PATH environment variable to point bat to a non-default +location of the configuration file. + +To generate a default configuration file, call: + +\fBbat --generate-config-file\fR +.SH "ADDING CUSTOM LANGUAGES" +bat supports Sublime Text \fB.sublime-syntax\fR language files, and can be +customized to add additional languages to your local installation. To do this, add the \fB.sublime-syntax\fR language +files to `\fB$(bat --config-dir)/syntaxes\fR` and run `\fBbat cache --build\fR`. + +\fBExample:\fR + +.RS 0.5i +mkdir -p "$(bat --config-dir)/syntaxes" +.br +cd "$(bat --config-dir)/syntaxes" + +# Put new '.sublime-syntax' language definition files +.br +# in this folder (or its subdirectories), for example: +.br +git clone https://github.com/tellnobody1/sublime-purescript-syntax + +# And then build the cache. +.br +bat cache --build +.RE + +Once the cache is built, the new language will be visible in `\fBbat --list-languages\fR`. +.br +If you ever want to remove the custom languages, you can clear the cache with `\fBbat cache --clear\fR`. + +.SH "ADDING CUSTOM THEMES" +Similarly to custom languages, bat supports Sublime Text \fB.tmTheme\fR themes. +These can be installed to `\fB$(bat --config-dir)/themes\fR`, and are added to the cache with +`\fBbat cache --build`. +.SH "MORE INFORMATION" + +For more information and up-to-date documentation, visit the bat repo: +.br +\fBhttps://github.com/sharkdp/bat\fR diff --git a/bat/bat.exe b/bat/bat.exe Binary files differnew file mode 100644 index 0000000..91a7847 --- /dev/null +++ b/bat/bat.exe |