1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-03 18:51:44 +00:00

Compare commits

...

238 Commits

Author SHA1 Message Date
sharkdp 6d981498d8 Bump version to 0.17.1 2020-11-24 21:40:11 +01:00
sharkdp bd2e9917da Revert "Add cycle detection integration tests"
This reverts commit ec60d84265.
2020-11-24 21:40:11 +01:00
sharkdp a6810e3353 Revert "Add io cycle detection with clircle"
This reverts commit aa2ae19dfd.
2020-11-24 21:40:11 +01:00
henil 591eba66a3 add new syntax test files 2020-11-23 15:43:58 +01:00
sharkdp a5a9ac83e5 Revert "Update dependencies"
This reverts commit 44a905d135.
2020-11-23 15:03:42 +01:00
sharkdp 15b122a448 Update syntax cache 2020-11-23 14:46:32 +01:00
sharkdp 44a905d135 Update dependencies 2020-11-23 14:44:01 +01:00
sharkdp 8884104e82 Bump version to v0.17.0 2020-11-23 14:41:32 +01:00
David Peter 277cc5fa21 Revert "invoke gzip with -n"
This reverts commit 21de52ebea.
2020-11-23 14:32:30 +01:00
David Peter 0cbd7d583c Revert "remove leading article from description"
This reverts commit 7c730d11c3.
2020-11-23 14:32:30 +01:00
David Peter 3c3fc92863 Revert "ensure copyright is mode 644"
This reverts commit 4a6b4fb632.
2020-11-23 14:32:30 +01:00
David Peter e69d650598 Revert "include years in copyright notice"
This reverts commit 9f91a7d797.
2020-11-23 14:32:30 +01:00
David Peter 9385c81882 Revert "include changelog in package"
This reverts commit 1d4cee11b7.
2020-11-23 14:32:30 +01:00
David Peter 1b84f9f1ae Revert "add Depends line"
This reverts commit 883cc964ae.
2020-11-23 14:32:30 +01:00
David Peter d879fbd8a1 Revert "change docs dir name to match package name"
This reverts commit e4370d8d3f.
2020-11-23 14:32:30 +01:00
sharkdp 1fbdef06aa Use unreachable!(…) 2020-11-23 14:25:01 +01:00
MarcoIeni f5531cc7fa remove all matches 2020-11-23 14:25:01 +01:00
MarcoIeni 2ccff145ed remove unuseful matches expression 2020-11-23 14:25:01 +01:00
MarcoIeni 43b2ee5e71 fix some clippy warnings 2020-11-23 14:25:01 +01:00
sharkdp 51463a4b41 Change Robot syntax name to 'Robot Framework' 2020-11-23 14:16:37 +01:00
Niklas Mohrin 4f0116bee7 Add cycle detection integration tests 2020-11-23 14:06:54 +01:00
Niklas Mohrin 31793cfa62 Add io cycle detection with clircle 2020-11-23 14:06:54 +01:00
Ethan P 6d75540d4e Merge pull request #1389 from nstickney/master
explain how to use bat as cat (no paging) (closes #1383)
2020-11-21 10:13:28 -08:00
Stick ba5cbe208f explain how to use bat as cat (no paging) 2020-11-20 11:25:45 -05:00
Janek 2b82203041 Update bug_report.md 2020-11-06 21:45:25 +01:00
sharkdp 35da065445 Add zsh completion fix to CHANGELOG 2020-11-06 21:25:27 +01:00
dependabot-preview[bot] 12a1fe3ad4 Bump git2 from 0.13.11 to 0.13.12
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.13.11 to 0.13.12.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.13.11...0.13.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:53:22 +01:00
dependabot-preview[bot] 91057f2a09 Bump assets/syntaxes/02_Extra/Terraform from 64208ea to 54d8350
Bumps [assets/syntaxes/02_Extra/Terraform](https://github.com/alexlouden/Terraform.tmLanguage) from `64208ea` to `54d8350`.
- [Release notes](https://github.com/alexlouden/Terraform.tmLanguage/releases)
- [Commits](https://github.com/alexlouden/Terraform.tmLanguage/compare/64208ea816d940e4b9c93f4a6b67d64c02a09825...54d8350c3c5929c921ea7561c932aa15e7d96c48)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:51:21 +01:00
dependabot-preview[bot] 15060f00a5 Bump assets/syntaxes/02_Extra/Elixir from 4ee539b to 4fb0189
Bumps [assets/syntaxes/02_Extra/Elixir](https://github.com/princemaple/elixir-sublime-syntax) from `4ee539b` to `4fb0189`.
- [Release notes](https://github.com/princemaple/elixir-sublime-syntax/releases)
- [Commits](https://github.com/princemaple/elixir-sublime-syntax/compare/4ee539b43d82388f449535f7316d69f5dfeaabb5...4fb01891dd17434dde42887bc821917a30f4e010)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:49:46 +01:00
dependabot-preview[bot] 1a82a03d5d Bump assets/themes/onehalf from 3aa42a3 to 8992311
Bumps [assets/themes/onehalf](https://github.com/sonph/onehalf) from `3aa42a3` to `8992311`.
- [Release notes](https://github.com/sonph/onehalf/releases)
- [Commits](https://github.com/sonph/onehalf/compare/3aa42a39ed3cddde0c53976a700b81b8a7067890...89923117bc49dd1e0c6b7fdd34bc6dc4d425fe1f)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:49:30 +01:00
dependabot-preview[bot] 4674105698 Bump assets/syntaxes/02_Extra/CMake from aba96a0 to 21e9698
Bumps [assets/syntaxes/02_Extra/CMake](https://github.com/zyxar/Sublime-CMakeLists) from `aba96a0` to `21e9698`.
- [Release notes](https://github.com/zyxar/Sublime-CMakeLists/releases)
- [Commits](https://github.com/zyxar/Sublime-CMakeLists/compare/aba96a0862369e9f960bb63a38e2d7563ea6475e...21e96989d604d64f12d518f4f17fc71fa3cdc505)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:48:24 +01:00
dependabot-preview[bot] ca3e9a385f Bump serde from 1.0.116 to 1.0.117
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.116 to 1.0.117.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.116...v1.0.117)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:47:31 +01:00
dependabot-preview[bot] f05c222221 Bump serde_yaml from 0.8.13 to 0.8.14
Bumps [serde_yaml](https://github.com/dtolnay/serde-yaml) from 0.8.13 to 0.8.14.
- [Release notes](https://github.com/dtolnay/serde-yaml/releases)
- [Commits](https://github.com/dtolnay/serde-yaml/compare/0.8.13...0.8.14)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 09:47:18 +01:00
Byron Alley 3dc5fc54df Import syntax regression test for Ruby Haml 2020-11-01 09:46:54 +01:00
Byron Alley bac84b4c8b Add sshd_config syntax highlighting test 2020-11-01 09:38:03 +01:00
dependabot-preview[bot] a5b9a80216 Bump console from 0.12.0 to 0.13.0
Bumps [console](https://github.com/mitsuhiko/console) from 0.12.0 to 0.13.0.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Changelog](https://github.com/mitsuhiko/console/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/console/compare/v0.12.0...v0.13.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 08:51:43 +01:00
dependabot-preview[bot] 142d5e60ec Bump globset from 0.4.5 to 0.4.6
Bumps [globset](https://github.com/BurntSushi/ripgrep) from 0.4.5 to 0.4.6.
- [Release notes](https://github.com/BurntSushi/ripgrep/releases)
- [Changelog](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/ripgrep/compare/globset-0.4.5...globset-0.4.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-01 07:25:24 +01:00
Ethan P 61f947a580 Merge pull request #1276 from tommilligan/style-rule
style: add component 'rule' for horizontal file delimiter
2020-10-31 23:14:00 -07:00
sharkdp c4bbf28862 Highlight ebuild/eclass files with shell syntax
Upstream patch: https://github.com/sublimehq/Packages/pull/2541

closes #1292
2020-10-30 22:33:23 +01:00
David Peter 9befa81e36 Merge pull request #1331 from priner/master
Add Ninja syntax highlighting
2020-10-30 20:06:44 +01:00
David Peter 414c7ac83d Fix trailing newline 2020-10-30 19:37:10 +01:00
David Peter 3a612f063e Merge branch 'master' into master 2020-10-30 19:36:27 +01:00
Ján Priner 9daea73bba Add Ninja highlight test 2020-10-30 19:14:51 +01:00
Nicholas L 8e8131590c Use platform based path concatenation 2020-10-30 08:04:14 +01:00
Nicholas L 3acfe790b9 Add extra themes help to output 2020-10-30 08:04:14 +01:00
sharkdp 877d9120c9 Add a new 'Feature request' section 2020-10-29 20:16:33 +01:00
sharkdp c15b88f250 Add new section on Development and New syntaxes/themes 2020-10-29 20:16:33 +01:00
sharkdp 2889e017cd More detailed description for CHANGELOG section 2020-10-29 20:16:33 +01:00
Adrian Rivera 47ea99090f Style changes on CONTRIBUTORS 2020-10-29 20:16:33 +01:00
Adrian Rivera 1c1ba04c41 Adds a CONTRIBUTORS file 2020-10-29 20:16:33 +01:00
Adrian Rivera 456216ab37 Update CHANGELOG.md 2020-10-29 20:16:33 +01:00
Adrian Rivera 49d7bf8c39 From a TODO in #1211. Add documentation for contributors.
This changes the README file and adds a new section `Contributors`.
This section includes instructions to remind contributors to make an
update to the changelog.
2020-10-29 20:16:33 +01:00
David Peter dade4cc6f3 Add reference to batdiff 2020-10-29 19:37:12 +01:00
Adrian Rivera c747ac181d Updates CHANGELOG entry 2020-10-29 19:33:58 +01:00
Adrian Rivera 9837948c3a Throws an error when bat is being user as pager.
As mentioned on #1334 `bat` should not be used as a value for `pager`,
this change checks both the balue of `bat` provided as a parameter or
as an environment variable.
2020-10-29 19:33:58 +01:00
Kyle Hubert 072fb380d8 Add Svelte as a syntax 2020-10-29 19:33:09 +01:00
Jessé Vermeulen 85594956cf Bring back delta to me to me 2020-10-29 19:22:38 +01:00
Jesse Vermeulen 88eba56607 Add git diff example to Integration docs
Part of https://github.com/sharkdp/bat/issues/448

Thanks to https://github.com/sharkdp/bat/pull/940
2020-10-29 19:22:38 +01:00
Horki cc6cf48256 1213: org mode highlight testing 2020-10-29 19:21:46 +01:00
Horki e571cb553b 1213: nix; added trailing new line 2020-10-25 21:03:30 +01:00
Horki bf9f6e872d 1312: nix; fixed src 2020-10-25 21:03:30 +01:00
Horki 8348c1b746 1213: nix; fix buildInputs arr 2020-10-25 21:03:30 +01:00
Horki 0a9744ac95 add nix highligh 2020-10-25 21:03:30 +01:00
sharkdp 95954b7c57 Update CHANGELOG 2020-10-25 19:09:52 +01:00
Armand Philippot a707f81726 Add Coldark in New Themes 2020-10-25 08:18:55 +01:00
Armand Philippot dae6664555 Update themes.bin - Coldark themes 2020-10-25 08:18:55 +01:00
sharkdp 9dd807344c Ignore 'all_themes_are_present' unit test by default 2020-10-25 08:18:55 +01:00
Armand Philippot 2ecebf8ff2 Add Coldark themes to unit test 2020-10-25 08:18:55 +01:00
Armand Philippot 6d3cb5f99f Add Coldark themes 2020-10-25 08:18:55 +01:00
Dobe Peter ec8072d51f Add PowerShell syntax test
Part of the work for issue #1213.

A short PowerShell script and the corresponding syntax-highlighted output
has been added. The script exhibits many of the peculiarities of the
PowerShell syntax.
2020-10-25 08:04:27 +01:00
Stefano Probst 7a7bb80e23 Add Git Config syntax test file
cc sharkdp/bat#1213
2020-10-24 14:45:54 +02:00
Alan Berndt 99ac5c3045 Add fairly complex nginx config.
This is to contribute to issue #1213.  I took some of the more
complicated servers I am running as examples.  Everything looks to be
correctly highlighted compared to vim's syntax highlighting.
2020-10-24 14:10:51 +02:00
R1tschY efab00a9de Add Git Attributes syntax test 2020-10-24 14:09:52 +02:00
Keith Hall 9ab0801ee1 Revert accidental regex literal -> unicode char change in Manpage syntax 2020-10-24 12:30:25 +02:00
Keith Hall cfdb853ea6 End highlighting of C code in man pages when no longer relevant 2020-10-24 12:30:25 +02:00
Keith Hall 41e857ea16 Highlight C code in all man pages sections 2020-10-24 12:30:25 +02:00
Frank Schmitt 5b2da2b08d #1213 expanded D test file 2020-10-24 12:28:15 +02:00
Frank Schmitt 5e0a608ea6 #1213 added very basic test file for D 2020-10-24 12:28:15 +02:00
R1tschY 3729aefb6f Add QML syntax test 2020-10-24 12:27:16 +02:00
henil 8a2122b4a4 Add test file for /etc/group 2020-10-24 12:26:41 +02:00
Tommaso Pifferi cc6f6fdb1d Add tests for Vue component syntax 2020-10-24 12:25:55 +02:00
Stefano Probst 5ec4936a4f Add Graphviz DOT example files
cc sharkdp/bat#1213
2020-10-24 12:25:09 +02:00
Stefano Probst be84682bcb Add MATLAB syntax test file
cc sharkdp/bat#1213
2020-10-24 12:22:46 +02:00
ubaumann b07f3b4e74 Add Salt State (SLS) test file 2020-10-23 19:40:13 +02:00
Ján Priner fc1f37d3df Add Ninja syntax highlighting 2020-10-20 19:32:14 +02:00
Zachary J. Rollyson a3f037773a feat: include dotfiles (.) in create_highlighted_versions.py search 2020-10-17 17:40:51 +02:00
Zachary J. Rollyson c71c8980cf feat: add syntax sample for dotEnv files 2020-10-17 17:40:51 +02:00
Albert Safin 6bf7b79f13 Fix zsh completion
* Fix completion for -p option (#1320)
* Use prefixed function names to avoid name clash
2020-10-17 16:54:39 +02:00
Keith Hall 5d9adc14e7 Include details about Manpage syntax improvements in the changelog 2020-10-17 16:46:18 +02:00
Keith Hall 575888d81b Fix Manpage C highlighting regression 2020-10-17 16:46:18 +02:00
sharkdp 3539d3e72d Add Manpage syntax regression test for select(2) 2020-10-17 16:46:18 +02:00
Keith Hall bb25111ca9 Improve Manpage syntax 2020-10-17 16:46:18 +02:00
Zachary J. Rollyson 3c756a65a6 feat: add syntax tests for sass 2020-10-17 16:41:11 +02:00
Matthieu Vion 8d574826c9 Added reStructuredText reference for syntax tests 2020-10-16 19:03:20 +02:00
Matthieu Vion 7c7eebbe83 Changed Makefile syntax test source
Now using Makefile from the Redis project
2020-10-16 14:22:59 +02:00
Matthieu Vion 57ad85814b Added Makefile to syntax tests
Make progress in #1213
2020-10-16 14:22:59 +02:00
Benjamin Sinkula 4b2b419400 Add Common Lisp syntax highlighting test files 2020-10-16 08:58:04 +02:00
Celeo b83716f0eb feat: add Nim syntax test file 2020-10-16 08:56:36 +02:00
Keith Hall 6872a4dd7f Fix small grammar mistake/typo in the readme 2020-10-15 09:10:29 +03:00
sharkdp 4d6b2fec13 Add PureScript syntax test 2020-10-14 08:43:11 +02:00
David Peter 57c1a7fd69 Formatting fix 2020-10-14 08:26:02 +02:00
sharkdp bf78b74db4 Minor README improvements 2020-10-14 08:24:20 +02:00
Terence f80fba4d24 Integrate README.md with new assets.md (#1293) 2020-10-14 08:18:11 +02:00
Pablo Santiago Blum de Aguiar d075d2b453 Make logo compatible with light and dark themes 2020-10-14 08:15:08 +02:00
Benjamin Sinkula 5650624822 Add ActionScript 3 syntax test 2020-10-14 08:07:20 +02:00
Saul Blanco Tejero bf07b0be58 Add Perl test file 2020-10-14 07:45:42 +02:00
Sebastian Andersson eeea53759b Add apache httpd.conf example 2020-10-14 07:43:38 +02:00
okezieuc a39f1e0f9b added new syntax highlighting files
I added a sample etc/hosts file and a sample requirements.txt file. I didn't know there was already a sample YAML file because it wasn't ticked in the issue so I added some extra syntax that I had in my own to the previous  example.yaml file.
2020-10-14 07:41:13 +02:00
Tom Milligan 1614f80366 add integration test for grid overriding rule 2020-10-12 09:04:57 +01:00
Tom Milligan e293c58bb0 update man pages 2020-10-12 09:04:57 +01:00
Tom Milligan 3015ebfba1 disable rule when grid enabled, and print warning 2020-10-12 09:04:57 +01:00
Tom Milligan d7da4f5f2b update changelog 2020-10-12 09:04:56 +01:00
Tom Milligan c1af6ff2e6 Add integration test for style rule 2020-10-12 09:04:27 +01:00
Tom Milligan aa4000cb0d style: add component 'rule' for horizontal file delimiter 2020-10-12 09:04:27 +01:00
sharkdp 33128d75f2 Use list.extend(…) 2020-10-11 22:18:14 +02:00
sharkdp bf87f37039 Better ask forgiveness than permission 2020-10-11 22:18:14 +02:00
sharkdp 62e715ff5b Formatting 2020-10-11 22:18:14 +02:00
sharkdp b3903175c8 Auto-format Rust code 2020-10-11 21:57:12 +02:00
Logan Saso de47bd2323 Added newline to multicharacter line of plaintext generation script 2020-10-11 21:31:34 +02:00
Logan Saso 19b55706ee Fixed file location in creation script 2020-10-11 21:31:34 +02:00
Logan Saso 6c68198d19 Updated creation script and README to match generation script 2020-10-11 21:31:34 +02:00
Logan Saso f3c760c25f #1244 Use [].copy and path.exists instead of more cumbersome solutions
#1244 Slightly optimized create_highlighted_versions.py so that it won't walk the source path when it should be skipping the file

#1244 Updated README.md in plaintext source folder

#1244 Added extra option loading from `bat_options` file in directory and significantly reduced size of plaintext source

#1244 Updated create_highlighted_versions.py to ignore README.md files and use the --show-all option for manually-defined binary files

#1244 Updated plaintext file with command

bat -A --no-config --style=plain --color=always --theme='1337' --italic-text=always src/Plaintext/plaintext.txt > highlighted/Plaintext/plaintext.txt

#1244 Added example plaintext file
2020-10-11 21:31:34 +02:00
Ethan P 24fe946c06 Merge pull request #1308 from okezieuc/add-php-file
added php test file
2020-10-11 12:25:15 -07:00
sharkdp de6680bdf2 Move syntax mapping section 2020-10-11 21:11:26 +02:00
David Peter 0a28da0cd0 Small improvement to the syntax mapping section 2020-10-11 21:07:56 +02:00
Ethan P a838ff47b5 Merge pull request #1307 from molcay/master
Add syntax tests for CpuInfo and MemInfo filetype
2020-10-11 11:58:59 -07:00
okezieuc 8bd078caeb updated the php commit
I reverted the commit and prevented the vue submodules from being affected
2020-10-11 19:58:53 +01:00
henil bce304a800 made requested changes 2020-10-11 20:54:37 +02:00
henil 206d3e7b91 fix a typo 2020-10-11 20:54:37 +02:00
henil 4be32cf746 add new section for sytax of file in README.md 2020-10-11 20:54:37 +02:00
henil 4ec6075f81 minor update to specify pattern matching on --map-syntax supports glob matching 2020-10-11 20:54:37 +02:00
henil aa00e0a6b0 fix section 2020-10-11 20:54:37 +02:00
henil bb7fae72c9 add a new syntax section 2020-10-11 20:54:37 +02:00
henil 7bd19640a2 add new --map-syntax example 2020-10-11 20:54:37 +02:00
okezieuc b7271a2a6d Revert "added php test file"
This reverts commit ecde418abb.
2020-10-11 19:53:36 +01:00
okezieuc ecde418abb added php test file
I added a sample test.php file that covers a lot of python syntax
2020-10-11 18:48:29 +01:00
M. Olcay TERCANLI 51036ced9d Add MemInfo syntax test 2020-10-11 19:19:11 +03:00
M. Olcay TERCANLI b6c1ec3a24 Add CpuInfo syntax test 2020-10-11 19:18:53 +03:00
Felipe Garcia 46004001cb Add Clojure syntax test. 2020-10-11 09:48:06 +02:00
Zachary J. Rollyson f10c8ce25e Add GraphQl syntax test sample 2020-10-11 09:46:25 +02:00
Ethan P acc370d345 Merge pull request #1305 from grg121/1213-dockerfile-syntax-highlighting-test
Add basic Dockerfile syntax highlighting test files
2020-10-10 15:20:57 -07:00
grg121 457ab84065 Add basic Dockerfile syntax highlighting test files 2020-10-10 21:43:11 +02:00
Zachary J. Rollyson 3bcb5452aa Add HTML syntax test sample 2020-10-10 19:13:55 +02:00
venky 1f0e53a44d Added BibTeX syntax tests 2020-10-10 19:13:05 +02:00
Benjamin Neff 2d5cf1d3cf Remove gitattributes for .bat/.cmd files to make all testfiles eol=lf 2020-10-09 23:28:08 +02:00
sharkdp a81254ed2a Fix line endings 2020-10-09 23:22:30 +02:00
Akshat Gadhwal fdef133d3d Update test.swift 2020-10-09 23:22:30 +02:00
Akshat Gadhwal fd01f0a0ee ADDED swift test file for syntax highlighting 2020-10-09 23:22:30 +02:00
sharkdp 5b095ed6f3 Fix line endings 2020-10-09 23:18:53 +02:00
Akshat Gadhwal e7a3f34959 ADDED test file for R 2020-10-09 23:18:53 +02:00
Daniel Wolbach 06d0c8f056 add CMake syntax highlighting test 2020-10-09 22:50:47 +02:00
Jacky Hui 4064b8ff14 Added test file for Erlang. 2020-10-09 07:38:08 +02:00
gahag 83ecc3d3ac Update changelog 2020-10-08 18:51:42 +02:00
gahag 6615eceb18 Code review: replace if let with equals operator 2020-10-08 18:51:42 +02:00
gahag 53f5a37f01 Code review
- Replace bools with enums
- Replace short flag with long flag
2020-10-08 18:51:42 +02:00
gahag bbef2f41ec Add -S flag to less when --wrap=never (closes #1255)
Prevent less from wrapping lines by setting the proper flag when `--wrap=never`.
If the user set a custom value for `--pager`, no additional flag is set.
2020-10-08 18:51:42 +02:00
Benjamin Neff b6e729abeb Add Diff syntax highlight test 2020-10-08 12:50:09 +02:00
Filip Czaplicki 5fe98689d4 test: x86-64 Assembly NASM syntax test 2020-10-07 18:00:33 +02:00
Daniel Wolbach 8832a96e82 add GLSL syntax highlighting test 2020-10-07 17:58:33 +02:00
R1tschY 09631ed119 Add Batch syntax test 2020-10-07 07:41:42 +02:00
Spencer Williams 9257c7ce20 Regenerate using a fresh latest build of bat 2020-10-07 07:40:15 +02:00
Spencer Williams b30f9a1677 Add sample Crystal file 2020-10-07 07:40:15 +02:00
Felipe Garcia e6c3f96931 Add Groovy syntax test. 2020-10-07 07:38:52 +02:00
Felipe Garcia 85ff81f238 Add Lua syntax test. 2020-10-07 07:37:19 +02:00
Niklas Sombert 5e0b7f013a Add support for comments after section headers (closes #1259)
There's no canonical definition of what's the INI syntax, but Python's `ConfigParser` supports comments after section headers:

```ini
[section] ; comment
```
2020-10-06 19:58:01 +02:00
Thiago Arrais aa205c6a9f Add CSV syntax hightlighting test 2020-10-06 19:47:33 +02:00
scott.eppler 44bfad24a1 Add Terraform example file for Syntax Highlighting 2020-10-06 19:40:41 +02:00
Gede Wahyu 13e01841ca pascal: add syntax highlight file 2020-10-06 07:44:38 +02:00
sharkdp a999975bc9 Add missing newline 2020-10-06 07:17:10 +02:00
Matthew Zegar edf30e1fa1 Added missing highlighted generated test file 2020-10-06 07:17:10 +02:00
Matthew Zegar f41bf2082a Added CSS syntax highlight file and folder 2020-10-06 07:17:10 +02:00
Ethan P 894d3f1722 Replace SCSS example with unlicensed one 2020-10-06 06:51:51 +02:00
Ethan P 83d96e2bbb Rename SASS tests to SCSS, since they're using SCSS syntax 2020-10-06 06:51:51 +02:00
uabua 7a180e22ff Add SQL syntax highlighting test 2020-10-05 23:39:01 +02:00
David Peter 3609700b5e Add keith-hall as a maintainer! 2020-10-05 23:11:10 +02:00
Ethan P 389f64df57 Merge pull request #1265 from yimmt/minor-manpage-changes
Fix spelling and use PROJECT_EXECUTABLE more
2020-10-05 13:56:23 -07:00
scott.eppler e85064e4cf Fix mismatch between syntax-test and hightlighted
I needed to re-run `update.sh` script one last time.
2020-10-05 22:03:27 +02:00
scott.eppler dd95f8b5cb Add example file for YAML highlighting
Relates to #1213
2020-10-05 22:03:27 +02:00
Niklas Sombert 975487f630 Add syntax highlighting test file for INI (#1213) 2020-10-05 21:09:24 +02:00
Timmy Xiao 4ba7546c65 Fix spelling and use PROJECT_EXECUTABLE more 2020-10-05 14:45:30 -04:00
sharkdp c97aa55163 Add manually converted syntax 2020-10-05 18:53:49 +02:00
dependabot-preview[bot] 2e1e30705a Bump assets/syntaxes/02_Extra/TypeScript from f21aba5 to 603ebb4
Bumps [assets/syntaxes/02_Extra/TypeScript](https://github.com/Microsoft/TypeScript-Sublime-Plugin) from `f21aba5` to `603ebb4`.
- [Release notes](https://github.com/Microsoft/TypeScript-Sublime-Plugin/releases)
- [Commits](https://github.com/Microsoft/TypeScript-Sublime-Plugin/compare/f21aba57c58e9434df8fc29e1bd2feddfea83b21...603ebb48b162bc453a0bb2cbb0192f3606819f6d)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-10-05 18:53:49 +02:00
Akshat Gadhwal c92ac809a5 added test.dart 2020-10-05 18:53:35 +02:00
DanielVip3 ec842e8d51 Added a JavaScript test file 2020-10-05 17:26:13 +02:00
henil 6d6e3900c3 add LICENSE 2020-10-05 17:25:37 +02:00
henil 0516a0d7a6 add .gitignore test 2020-10-05 17:25:37 +02:00
henil adbbe158db forgot to update highlighted file after changing 2020-10-05 14:24:16 +02:00
henil 6d2be4a305 License attribution not required 2020-10-05 14:24:16 +02:00
henil 78c9a5d45b add julia test file 2020-10-05 14:24:16 +02:00
Mithil Poojary 5fa1645165 Add Java file test 2020-10-05 13:56:43 +02:00
sharkdp bbf6ec0458 Try to fix syntax-detection tests on Windows 2020-10-05 09:07:57 +02:00
Mithil Poojary e58b20f68d Add C file test 2020-10-05 09:06:47 +02:00
Logan Saso 0ce697daba #1241 Added newline to end of example.xml 2020-10-05 09:02:56 +02:00
Logan Saso a2dfadc6c8 #1213 Added example xml file 2020-10-05 09:02:56 +02:00
Mithil Poojary 6df8b3fe72 Print error message if bat not found on path 2020-10-05 09:01:46 +02:00
Mithil Poojary b623adc6df Add Cpp file test 2020-10-05 09:01:34 +02:00
Matthias Reitinger 2f77da7813 Add /etc/passwd syntax test file 2020-10-05 07:22:54 +02:00
Jonatas 9897c99190 Haskell highligth test 2020-10-05 07:20:00 +02:00
Giorgi Beriashvili aebc30447f Add TeX syntax highlighting test files 2020-10-05 07:19:07 +02:00
Giorgi Beriashvili d2bae54ed0 Add C-Sharp (C#) syntax highlighting test files 2020-10-05 07:15:09 +02:00
Logan Saso 501c369f39 #1213 Added example Markdown file 2020-10-05 07:14:09 +02:00
Filip Czaplicki db3468a815 test: ARM Assembly syntax test file 2020-10-05 07:12:24 +02:00
Filip Czaplicki 3aabed44ce test: Kotlin syntax test file 2020-10-05 07:11:52 +02:00
Ethan P 3af7a6b082 Merge pull request #1226 from mdevlamynck/fix-scripts
Shell script improvements
2020-10-04 13:49:50 -07:00
Daniil Baturin 2e985198c6 Add a protobuf syntax sample. 2020-10-04 21:32:09 +02:00
Celeo 74a2ef8138 test: add Jinja2 syntax test file 2020-10-04 21:31:19 +02:00
Daniil Baturin 88ea21b276 Add an SML syntax test file. 2020-10-04 21:25:05 +02:00
Michael 62397dbd0b test: add newline to JSON syntax source file 2020-10-04 21:22:57 +02:00
Michael 317b086f66 test: add json highlight test 2020-10-04 21:22:57 +02:00
Matthias Devlamynck 12340c1d10 Add change dir to script dir to allow running from project root dir 2020-10-04 19:35:32 +02:00
parksb e747199711 Generate highlighted file on latest version 2020-10-04 15:25:39 +02:00
parksb df7ce883c7 Add texts indicating source to LICENSE.md 2020-10-04 15:25:39 +02:00
parksb eb3e2dca24 Add basic typescript test file 2020-10-04 15:25:39 +02:00
Michael 2d9b936b0a test: add asciidoc highlight test 2020-10-04 15:23:49 +02:00
Matthias Devlamynck 66c7aca2f6 Add elm syntax regression test 2020-10-04 15:19:54 +02:00
Nick Anthony Flueckiger 0c3344d0c4 Add a ruby source code syntax test with source and output 2020-10-04 15:15:34 +02:00
Quang Le 0ac211140a document: Update README.md using cargo install --path 2020-10-04 13:29:52 +02:00
Quang Le 5d490664ca fix: update original file in license 2020-10-04 13:26:05 +02:00
Quang Le d170dd305d Add scala code highlight test 2020-10-04 13:26:05 +02:00
Matthias Devlamynck b50bd58795 Replace #!/bin/bash with #!/usr/bin/env bash to improve compatibility with systems where /bin/bash is not available 2020-10-04 11:51:07 +02:00
David Peter 1da279a290 Add link to original source 2020-10-04 11:25:11 +02:00
Quang Le 100b9a470b test: add go highlight test 2020-10-04 11:25:11 +02:00
Daniil Baturin 43c2b36eaa Make tests/syntax-tests/update.sh shell script executable. 2020-10-04 11:17:23 +02:00
Daniil Baturin 203d0bd8ae Add an OCaml file for syntax tests. 2020-10-04 11:16:15 +02:00
Thomas Gotwig 14092fbadb Apply requested changes regarding Homebrew 🍺 2020-10-04 11:14:32 +02:00
Thomas Gotwig 35ad76771d Mention Homebrew on Linux 🍺🐧 2020-10-04 11:14:32 +02:00
Ethan P 96151c44aa Add a batgrep as Bash script syntax tests 2020-10-04 11:00:57 +02:00
Ethan P 02dcb01120 Add a simple Bash script for syntax tests 2020-10-04 11:00:57 +02:00
Ethan P 51d25e5859 Fix syntax highlighting test update.sh to work on Mac OS 2020-10-04 11:00:57 +02:00
henil b8535689d3 update CHANGELOG.md 2020-10-04 06:33:11 +02:00
henil 8ff890635f add an after help NOTE 2020-10-04 06:33:11 +02:00
José Eduardo 29b6ba0758 Added Elixir file example 2020-10-03 22:33:44 +02:00
adgai19 ca5793dbea Added Basic python test file 2020-10-03 22:32:59 +02:00
Yoichi NAKAYAMA 0fdaa8e745 Remove unnecessary white spaces 2020-10-03 17:51:36 +02:00
Yoichi NAKAYAMA 5a71044d5a Merge the change in fca83bf7 and 6e3e7daf 2020-10-03 17:51:36 +02:00
Yoichi NAKAYAMA 8d091051af Merge the change in 1f177f0a 2020-10-03 17:51:36 +02:00
Yoichi NAKAYAMA 34da1ef9d6 less is just an example for PAGER
Merge the change in b0f88412 and febe3358
2020-10-03 17:51:36 +02:00
谭九鼎 e31e35c46b CI: use checkout v2 2020-10-03 13:13:40 +02:00
288 changed files with 19601 additions and 642 deletions
+2 -2
View File
@@ -28,11 +28,11 @@ If you're on Windows:
**Describe the bug you encountered:** **Describe the bug you encountered:**
... ...
**Describe what you expected to happen?** **What did you expect to happen instead?**
... ...
**How did you install `bat`?** **How did you install `bat`?**
apt-get, homebrew, GitHub release, etc. <!-- apt-get, homebrew, GitHub release, etc. -->
--- ---
+17 -30
View File
@@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Git checkout - name: Git checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }}) - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Git checkout - name: Git checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
with: with:
submodules: true # we need all syntax and theme submodules submodules: true # we need all syntax and theme submodules
- name: Install Rust toolchain - name: Install Rust toolchain
@@ -58,6 +58,11 @@ jobs:
with: with:
command: test command: test
args: --release args: --release
- name: Run ignored-by-default unit tests with new syntaxes and themes
uses: actions-rs/cargo@v1
with:
command: test
args: --release -- --ignored
- name: Syntax highlighting regression test - name: Syntax highlighting regression test
run: tests/syntax-tests/regression_test.sh run: tests/syntax-tests/regression_test.sh
- name: List of languages - name: List of languages
@@ -87,7 +92,7 @@ jobs:
- { os: windows-latest , target: x86_64-pc-windows-msvc } - { os: windows-latest , target: x86_64-pc-windows-msvc }
steps: steps:
- name: Git checkout - name: Git checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Install prerequisites - name: Install prerequisites
shell: bash shell: bash
run: | run: |
@@ -269,7 +274,6 @@ jobs:
shell: bash shell: bash
run: | run: |
ARCHIVE_DIR='${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/' ARCHIVE_DIR='${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
COPYRIGHT_YEARS="2018 - "$(date "+%Y")
# Binary # Binary
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "$ARCHIVE_DIR" cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "$ARCHIVE_DIR"
@@ -279,8 +283,8 @@ jobs:
# Man page # Man page
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "$ARCHIVE_DIR" cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "$ARCHIVE_DIR"
# README, LICENSE and CHANGELOG files # README and LICENSE files
cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR" cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "$ARCHIVE_DIR"
# Autocompletion files # Autocompletion files
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.fish" cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.fish"
@@ -302,41 +306,26 @@ jobs:
install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" install -Dm755 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}"
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
# Work out shared library dependencies
# dpkg-shlibdeps requires debian/control file. Dummy it and clean up
mkdir "./debian"
touch "./debian/control"
case ${{ matrix.job.target }} in
aarch64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -l/usr/aarch64-linux-gnu/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
arm-*-linux-*hf) DEPENDS="$(dpkg-shlibdeps -l/usr/arm-linux-gnueabihf/lib -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
i686-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
x86_64-*-linux-*) DEPENDS="$(dpkg-shlibdeps -O "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}" 2> /dev/null | sed 's/^shlibs:Depends=//')" ;;
esac;
rm -rf "./debian"
# Man page # Man page
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1" install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1" gzip --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
# Autocompletion files # Autocompletion files
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish" install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish"
install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}" install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"
# README and LICENSE # README and LICENSE
install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/README.md" install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/README.md"
install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/LICENSE-MIT" install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/LICENSE-MIT"
install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/LICENSE-APACHE" install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/LICENSE-APACHE"
install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/changelog"
gzip -n --best "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/changelog"
cat > "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/copyright" <<EOF cat > "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/copyright" <<EOF
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ${{ env.PROJECT_NAME }} Upstream-Name: ${{ env.PROJECT_NAME }}
Source: ${{ env.PROJECT_HOMEPAGE }} Source: ${{ env.PROJECT_HOMEPAGE }}
Files: * Files: *
Copyright: ${{ env.PROJECT_MAINTAINER }} Copyright: ${{ env.PROJECT_MAINTAINER }}
Copyright: $COPYRIGHT_YEARS ${{ env.PROJECT_MAINTAINER }}
License: Apache-2.0 or MIT License: Apache-2.0 or MIT
License: Apache-2.0 License: Apache-2.0
@@ -368,7 +357,6 @@ jobs:
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
EOF EOF
chmod 644 "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/copyright"
# control file # control file
mkdir -p "${DPKG_DIR}/DEBIAN" mkdir -p "${DPKG_DIR}/DEBIAN"
@@ -380,10 +368,9 @@ jobs:
Maintainer: ${{ env.PROJECT_MAINTAINER }} Maintainer: ${{ env.PROJECT_MAINTAINER }}
Homepage: ${{ env.PROJECT_HOMEPAGE }} Homepage: ${{ env.PROJECT_HOMEPAGE }}
Architecture: ${{ steps.vars.outputs.DPKG_ARCH }} Architecture: ${{ steps.vars.outputs.DPKG_ARCH }}
Depends: $DEPENDS
Provides: ${{ env.PROJECT_NAME }} Provides: ${{ env.PROJECT_NAME }}
Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }} Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}
Description: cat(1) clone with wings. Description: A cat(1) clone with wings.
A cat(1) clone with syntax highlighting and Git integration. A cat(1) clone with syntax highlighting and Git integration.
EOF EOF
@@ -412,7 +399,7 @@ jobs:
- { os: macos-latest , toolchain: nightly-2020-04-29 } - { os: macos-latest , toolchain: nightly-2020-04-29 }
- { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu } - { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v2
- name: Initialize workflow variables - name: Initialize workflow variables
id: vars id: vars
shell: bash shell: bash
+9
View File
@@ -197,3 +197,12 @@
[submodule "assets/syntaxes/02_Extra/Apache"] [submodule "assets/syntaxes/02_Extra/Apache"]
path = assets/syntaxes/02_Extra/Apache path = assets/syntaxes/02_Extra/Apache
url = https://github.com/colinta/ApacheConf.tmLanguage url = https://github.com/colinta/ApacheConf.tmLanguage
[submodule "assets/syntaxes/02_Extra/Ninja"]
path = assets/syntaxes/02_Extra/Ninja
url = https://github.com/pope/SublimeNinja.git
[submodule "assets/syntaxes/02_Extra/Svelte"]
path = assets/syntaxes/02_Extra/Svelte
url = https://github.com/corneliusio/svelte-sublime
[submodule "assets/themes/Coldark"]
path = assets/themes/Coldark
url = https://github.com/ArmandPhilippot/coldark-bat.git
+36
View File
@@ -1,5 +1,6 @@
# unreleased # unreleased
## Features ## Features
## Bugfixes ## Bugfixes
@@ -14,6 +15,41 @@
## Packaging ## Packaging
# 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 # v0.16.0
## Features ## Features
+48
View File
@@ -0,0 +1,48 @@
# Contributing
Thank you for considering to contribute to `bat`!
## Add an entry to the changelog
If your contribution changes the behavior of `bat` (as opposed to a typo-fix
in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
and describe your changes. This makes the release proess much easier and
therefore helps to get your changes into a new `bat` release faster.
The top of the `CHANGELOG` contains a *"unreleased"* section with a few
subsections (Features, Bugfixes, …). Please add your entry to the subsection
that best describes your change
Entries follow this format:
```
- Short description of what has been changed, see #123 (@user)
```
Here, `#123` is the number of the original issue and/or your pull request.
Please replace `@user` by your GitHub username.
## Development
Please check out the [Development](https://github.com/sharkdp/bat#development)
section in the README.
## Adding a new feature
Please consider opening a
[feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md)
first in order to give us a chance to discuss the feature first.
## Adding new syntaxes/languages or themes
Before you make a pull request that adds a new syntax or theme, please read
the [Customization](https://github.com/sharkdp/bat#customization) section
in the README first.
If you really think that a particular syntax or theme should be added for all
users, please read the corresponding
[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
first.
Generated
+395 -407
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
name = "bat" name = "bat"
readme = "README.md" readme = "README.md"
repository = "https://github.com/sharkdp/bat" repository = "https://github.com/sharkdp/bat"
version = "0.16.0" version = "0.17.1"
exclude = [ exclude = [
"assets/syntaxes/*", "assets/syntaxes/*",
"assets/themes/*", "assets/themes/*",
@@ -38,7 +38,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
atty = { version = "0.2.14", optional = true } atty = { version = "0.2.14", optional = true }
ansi_term = "^0.12.1" ansi_term = "^0.12.1"
ansi_colours = "^1.0" ansi_colours = "^1.0"
console = "0.12.0" console = "0.13.0"
dirs = { version = "3.0", optional = true } dirs = { version = "3.0", optional = true }
lazy_static = { version = "1.4", optional = true } lazy_static = { version = "1.4", optional = true }
wild = { version = "2.0", optional = true } wild = { version = "2.0", optional = true }
+87 -34
View File
@@ -38,14 +38,14 @@ characters:
### Automatic paging ### Automatic paging
`bat` can pipe its own output to a pager (e.g `less`) if the output is too large for one screen. 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 #### File concatenation
Oh.. you can also use it to concatenate files :wink:. Whenever Even with a pager set, you can still use `bat` to concatenate files :wink:.
`bat` detects a non-interactive terminal (i.e. when you pipe into another process 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.
or into a file), `bat` will act as a drop-in replacement for `cat` and
fall back to printing the plain file contents.
## How to use ## How to use
@@ -131,7 +131,18 @@ highlighting:
git show v0.6.0:src/main.rs | bat -l rs git show v0.6.0:src/main.rs | bat -l rs
``` ```
Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out [`delta`](https://github.com/dandavison/delta). #### `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 --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` #### `xclip`
@@ -200,7 +211,7 @@ 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: [release page](https://github.com/sharkdp/bat/releases) and install it via:
```bash ```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
``` ```
### On Alpine Linux ### On Alpine Linux
@@ -276,14 +287,16 @@ You can install `bat` with zypper:
zypper install bat zypper install bat
``` ```
### On macOS ### On macOS (or Linux) via Homebrew
You can install `bat` with [Homebrew](http://braumeister.org/formula/bat): 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 ```bash
brew install bat brew install bat
``` ```
### On macOS via MacPorts
Or install `bat` with [MacPorts](https://ports.macports.org/port/bat/summary): Or install `bat` with [MacPorts](https://ports.macports.org/port/bat/summary):
```bash ```bash
@@ -334,7 +347,7 @@ higher. You can then use `cargo` to build everything:
cargo install --locked bat cargo install --locked bat
``` ```
Note that addition files like the man page or shell completion 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`). 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 ## Customization
@@ -389,35 +402,45 @@ variable to make these changes permanent or use `bat`s
### Adding new syntaxes / language definitions ### 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/) `bat` uses the excellent [`syntect`](https://github.com/trishume/syntect/)
library for syntax highlighting. `syntect` can read any library for syntax highlighting. `syntect` can read any
[Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html) [Sublime Text `.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html)
and theme. To add new syntax definitions, do the following. and theme.
Create a folder with syntax definition files: A good resource for finding Sublime Syntax packages is [Package Control](https://packagecontrol.io/). Once you found a
syntax:
```bash 1. Create a folder with syntax definition files:
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
# Put new '.sublime-syntax' language definition files ```bash
# in this folder (or its subdirectories), for example: mkdir -p "$(bat --config-dir)/syntaxes"
git clone https://github.com/tellnobody1/sublime-purescript-syntax cd "$(bat --config-dir)/syntaxes"
```
Now use the following command to parse these files into a binary cache: # Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
git clone https://github.com/tellnobody1/sublime-purescript-syntax
```
```bash 2. Now use the following command to parse these files into a binary cache:
bat cache --build
```
Finally, use `bat --list-languages` to check if the new languages are available. ```bash
bat cache --build
```
If you ever want to go back to the default settings, call: 3. Finally, use `bat --list-languages` to check if the new languages are available.
```bash If you ever want to go back to the default settings, call:
bat cache --clear
``` ```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 ### Adding new themes
@@ -437,6 +460,33 @@ bat cache --build
Finally, use `bat --list-themes` to check if the new themes are available. 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)full .
Note: You probably want to use this option as an entry in `bat`s configuration file instead
of passing it on the command line (see below).
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 ### Using a different pager
`bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not `bat` uses the pager that is specified in the `PAGER` environment variable. If this variable is not
@@ -488,6 +538,7 @@ and the `GitHub` theme when in the _light mode_.
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)" alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
``` ```
## Configuration file ## Configuration file
`bat` can also be customized with a configuration file. The location of the file is dependent `bat` can also be customized with a configuration file. The location of the file is dependent
@@ -524,9 +575,6 @@ Example configuration file:
# Use C++ syntax for .ino files # Use C++ syntax for .ino files
--map-syntax "*.ino:C++" --map-syntax "*.ino:C++"
# Use ".gitignore"-style highlighting for ".ignore" files
--map-syntax ".ignore:Git Ignore"
``` ```
## Using `bat` on Windows ## Using `bat` on Windows
@@ -621,17 +669,22 @@ cargo build --bins
cargo test cargo test
# Install (release version) # Install (release version)
cargo install --locked cargo install --path . --locked
# Build a bat binary with modified syntaxes and themes # Build a bat binary with modified syntaxes and themes
bash assets/create.sh bash assets/create.sh
cargo install --locked --force cargo install --path . --locked --force
``` ```
## Contributing
Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
## Maintainers ## Maintainers
- [sharkdp](https://github.com/sharkdp) - [sharkdp](https://github.com/sharkdp)
- [eth-p](https://github.com/eth-p) - [eth-p](https://github.com/eth-p)
- [keith-hall](https://github.com/keith-hall)
## Project goals and alternatives ## Project goals and alternatives
+8 -8
View File
@@ -3,8 +3,8 @@
local context state state_descr line local context state state_descr line
typeset -A opt_args typeset -A opt_args
(( $+functions[_cache_subcommand] )) || (( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) ||
_cache_subcommand() { _{{PROJECT_EXECUTABLE}}_cache_subcommand() {
local -a args local -a args
args=( args=(
'(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]' '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
@@ -19,12 +19,12 @@ _cache_subcommand() {
_arguments -S -s $args _arguments -S -s $args
} }
(( $+functions[_main] )) || (( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) ||
_main() { _{{PROJECT_EXECUTABLE}}_main() {
local -a args local -a args
args=( args=(
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]' '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
{-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)' '*'{-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' '(-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>...' '(-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' '(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
@@ -79,15 +79,15 @@ if (( ${#words} == 2 )); then
local -a subcommands local -a subcommands
subcommands=('cache:Modify the syntax-definition and theme cache') subcommands=('cache:Modify the syntax-definition and theme cache')
_describe subcommand subcommands _describe subcommand subcommands
_main _{{PROJECT_EXECUTABLE}}_main
else else
case $words[2] in case $words[2] in
cache) cache)
_cache_subcommand _{{PROJECT_EXECUTABLE}}_cache_subcommand
;; ;;
*) *)
_main _{{PROJECT_EXECUTABLE}}_main
;; ;;
esac esac
fi fi
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+7 -7
View File
@@ -90,7 +90,7 @@ values: *auto*, never, always.
\fB\-f\fR, \fB\-\-force\-colorization\fR \fB\-f\fR, \fB\-\-force\-colorization\fR
.IP .IP
Alias for '--decorations=always --color=always'. This is useful \ Alias for '--decorations=always --color=always'. This is useful \
if the output of bat is piped to another program, but you want \ if the output of {{PROJECT_EXECUTABLE}} is piped to another program, but you want \
to keep the colorization/decorations. to keep the colorization/decorations.
.HP .HP
\fB\-\-paging\fR <when> \fB\-\-paging\fR <when>
@@ -129,7 +129,7 @@ Configure which elements (line numbers, file headers, grid borders, Git modifica
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full'). 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 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 export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
values: *auto*, full, plain, changes, header, grid, numbers, snip. values: *auto*, full, plain, changes, header, grid, rule, numbers, snip.
.HP .HP
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>... \fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
.IP .IP
@@ -174,12 +174,12 @@ is dependent on your operating system. To get the default path for your system,
\fB{{PROJECT_EXECUTABLE}} --config-file\fR \fB{{PROJECT_EXECUTABLE}} --config-file\fR
Alternatively, you can use the BAT_CONFIG_PATH environment variable to point bat to a non-default Alternatively, you can use the BAT_CONFIG_PATH environment variable to point {{PROJECT_EXECUTABLE}} to a non-default
location of the configuration file. location of the configuration file.
.SH "ADDING CUSTOM LANGUAGES" .SH "ADDING CUSTOM LANGUAGES"
{{PROJECT_EXECUTABLE}} supports Sublime Text \fB.sublime-syntax\fR language files, and can be {{PROJECT_EXECUTABLE}} 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-snytax\fR language customized to add additional languages to your local installation. To do this, add the \fB.sublime-syntax\fR language
files to `\fB$({{PROJECT_EXECUTABLE}} --config-dir)/syntaxes\fR` and run `\fBbat cache --build\fR`. files to `\fB$({{PROJECT_EXECUTABLE}} --config-dir)/syntaxes\fR` and run `\fB{{PROJECT_EXECUTABLE}} cache --build\fR`.
\fBExample:\fR \fBExample:\fR
@@ -199,9 +199,9 @@ git clone https://github.com/tellnobody1/sublime-purescript-syntax
{{PROJECT_EXECUTABLE}} cache --build {{PROJECT_EXECUTABLE}} cache --build
.RE .RE
Once the cache is built, the new language will be visible in `\fBbat --list-languages\fR`. Once the cache is built, the new language will be visible in `\fB{{PROJECT_EXECUTABLE}} --list-languages\fR`.
.br .br
If you ever want to remove the custom languages, you can clear the cache with `\fBbat cache --clear\fR`. If you ever want to remove the custom languages, you can clear the cache with `\fB{{PROJECT_EXECUTABLE}} cache --clear\fR`.
.SH "ADDING CUSTOM THEMES" .SH "ADDING CUSTOM THEMES"
Similarly to custom languages, {{PROJECT_EXECUTABLE}} supports Sublime Text \fB.tmTheme\fR themes. Similarly to custom languages, {{PROJECT_EXECUTABLE}} supports Sublime Text \fB.tmTheme\fR themes.
+15
View File
@@ -0,0 +1,15 @@
diff --git syntaxes/01_Packages/ShellScript/Bash.sublime-syntax syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
index e973e319..a703cef8 100644
--- syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
+++ syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
@@ -30,8 +30,8 @@ file_extensions:
- .zshenv
- .zshrc
- PKGBUILD # https://jlk.fjfi.cvut.cz/arch/manpages/man/PKGBUILD.5
- - .ebuild
- - .eclass
+ - ebuild
+ - eclass
first_line_match: |
(?x)
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -25,12 +25,13 @@ contexts:
scope: comment.line.semicolon.ini scope: comment.line.semicolon.ini
captures: captures:
1: punctuation.definition.comment.ini 1: punctuation.definition.comment.ini
- match: '^\s*(\[)(.*?)(\])' - match: '^\s*(\[)(.*?)(\])\s*(;.*)?$\n?'
scope: meta.tag.section.ini scope: meta.tag.section.ini
captures: captures:
1: punctuation.definition.section.ini 1: punctuation.definition.section.ini
2: entity.section.ini 2: entity.section.ini
3: punctuation.definition.section.ini 3: punctuation.definition.section.ini
4: comment.definition.section.ini
- match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?' - match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?'
scope: meta.declaration.ini scope: meta.declaration.ini
captures: captures:
+138 -28
View File
@@ -7,47 +7,157 @@ file_extensions:
scope: source.man scope: source.man
variables: variables:
section_heading: '^\S.*$' section_heading: '^(?!#)\S.*$'
command_line_option: '(--?[A-Za-z0-9][_A-Za-z0-9-]*)'
contexts: contexts:
prototype:
# ignore syntax test lines
- match: '^#'
push:
- meta_scope: comment.syntax-test.man
- match: $\n?
pop: true
main: main:
- match: ^ - match: ^
push: first_line push: first_line
first_line: first_line:
- match: '([A-Z0-9_\-]+)(\()([^)]+)(\))' - match: '([A-Z0-9_\-]+)(\()([^)]+)(\))\s*'
captures: captures:
1: meta.preprocessor 1: meta.preprocessor.man
2: keyword.operator 2: keyword.operator.man
3: string.quoted.other 3: string.quoted.other.man
4: keyword.operator 4: keyword.operator.man
push:
- match: '$' - match: (?:[\w'-]+|\s(?!\s))
push: body scope: markup.heading.title.man
- match: \s\s
body: pop: true
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)' - match: '(?=\S|$)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
pop: true pop: true
- match: '^\S.*$' - match: '$'
scope: markup.heading set: body
body:
# English, ..., ..., ..., Russian, ...
- match: '^(?:SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
scope: markup.heading.synopsis.man
embed: synopsis
escape: '(?={{section_heading}})'
- match: '^(?:USAGE)'
scope: markup.heading.synopsis.man
embed: synopsis
escape: '(?={{section_heading}})'
- match: '{{section_heading}}'
scope: markup.heading.other.man
embed: options # some man pages put command line options under the description heading
escape: '(?={{section_heading}})'
function-call:
- match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))' - match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
captures: captures:
1: entity.name.function 1: entity.name.function.man
2: keyword.operator 2: keyword.operator.man
3: constant.numeric 3: constant.numeric.man
4: keyword.operator 4: keyword.operator.man
options:
# command-line options like --option=value, --some-flag, or -x # command-line options like --option=value, --some-flag, or -x
- match: '(?:[^a-zA-Z0-9_-]|^|\s)(--?[A-Za-z0-9][A-Za-z0-9-]*)(?:(=)?("?)([A-Za-z0-9]+)("?))?' - match: '^[ ]{7}(?=-)'
push: expect-command-line-option
- match: '(?:[^a-zA-Z0-9_-]|^|\s){{command_line_option}}'
captures: captures:
1: entity.name 1: entity.name.command-line-option
2: keyword.operator push:
3: punctuation.definition.string.begin - match: '='
4: variable.parameter scope: keyword.operator.man
3: punctuation.definition.string.end set:
- match: '[^],.() ]+'
scope: variable.parameter.man
pop: true
- match: $
pop: true
- match: ''
pop: true
- include: function-call
- include: c-code
expect-command-line-option:
- match: '[A-Za-z0-9-]+'
scope: entity.name.command-line-option.man
- match: '(\[)(=)'
captures:
1: punctuation.section.brackets.begin.man
2: keyword.operator.man
push: [command-line-option-or-pipe, expect-parameter]
- match: '\['
push:
- meta_scope: entity.name.command-line-option.man
- match: '\]'
pop: true
- match: '='
scope: keyword.operator.man
push: expect-parameter
- match: (?=.*\.)
pop: true
- match: '\s'
push: expect-parameter
- match: '(,)\s*'
captures:
1: punctuation.separator.man
- match: $|(?=\])
pop: true
expect-parameter:
- match: '[A-Za-z0-9-]+'
scope: variable.parameter.man
- match: (?=\s+\|)
pop: true
- match: \|
scope: keyword.operator.logical.man
- match: '\['
scope: punctuation.section.brackets.begin.man
push:
- match: '\]'
scope: punctuation.section.brackets.end.man
pop: true
- include: expect-parameter
- match: '$|(?=[],]|{{command_line_option}})'
pop: true
c-code:
- match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))'
embed: scope:source.c
#embed_scope: source.c.embedded.man
#escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b))
escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z])))
synopsis:
- include: c-code
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe
- include: options
command-line-option-or-pipe:
- match: (\|)\s*
captures:
1: keyword.operator.logical.man
#- match: (?={{command_line_option}})
- match: \w+-\w+
- match: (?=-)
push:
- match: (?=\s*\|)
pop: true
- include: expect-command-line-option
- match: \]
scope: punctuation.section.brackets.end.man
pop: true
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe
+52
View File
@@ -0,0 +1,52 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Ninja
file_extensions:
- ninja
scope: source.ninja
contexts:
main:
- match: (#).*$\n?
comment: Comment line.
scope: comment.line.number-sign.ninja
captures:
1: punctuation.definition.comment.ninja
- match: ^(rule)\b
comment: Rule keyword and keywords for a rule.
captures:
1: keyword.other.ninja
push:
- match: ^(?=\S)
pop: true
- include: main
- match: \b(?:command|deps|depfile|description|generator|pool|restat|rspfile|rspfile_content)\b
scope: keyword.other.ninja
- match: ^(pool)\b
comment: Pool keyword and keywords for a pool.
captures:
1: keyword.other.ninja
push:
- match: ^(?=\S)
pop: true
- include: main
- match: \b(?:depth)\b
scope: keyword.other.ninja
- match: ^(?:build|rule|default|include|subninja)\b
comment: Other Keywords.
scope: keyword.other.ninja
- match: '(?:[=:]|\|{1,2})(?=\s)'
comment: Operators for variable assignment (=), rule definition (:), implicit (|) and order only (||) dependencies.
scope: keyword.operator.ninja
- match: \$$
comment: Line wrap.
scope: keyword.operator.ninja
- match: \$\$
comment: Dollar literal.
scope: keyword.operator.ninja
- match: '\$[[:alnum:]_-]+'
comment: Simple variables, e.g. $var.
scope: variable.other.ninja
- match: '\${[[:alnum:]_.-]+}'
comment: "Variables, e.g. ${some.var.name}."
scope: variable.other.ninja
+1 -1
View File
@@ -1,7 +1,7 @@
%YAML 1.2 %YAML 1.2
--- ---
# http://www.sublimetext.com/docs/3/syntax.html # http://www.sublimetext.com/docs/3/syntax.html
name: Robot Framework syntax highlighting. name: Robot Framework
file_extensions: file_extensions:
- robot - robot
scope: source.robot scope: source.robot
+7
View File
@@ -3084,6 +3084,13 @@ contexts:
captures: captures:
0: meta.brace.square.ts 0: meta.brace.square.ts
pop: true pop: true
- match: \.\.\.
scope: keyword.operator.rest.ts
- match: '(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))([_$[:alpha:]][_$[:alnum:]]*)\s*(\?)?\s*(:)'
captures:
1: entity.name.label.ts
2: keyword.operator.optional.ts
3: punctuation.separator.label.ts
- include: type - include: type
- include: punctuation-comma - include: punctuation-comma
typeof-operator: typeof-operator:
+151
View File
@@ -0,0 +1,151 @@
# SYNTAX TEST "Manpage.sublime-syntax"
SOMETHING(8) System Manager's Manual SOMETHING(8)
# ^^^^^ meta.preprocessor
# ^^^^^^^^^^^^^^^^^^^^^^^ markup.heading.title
# ^^^^^^^ meta.preprocessor
NAME
#^^^ markup.heading.other
example - do something useful
SYNOPSIS
example [options] [--home DIR] [--shell SHELL] [--no-create-home]
# ^ punctuation.section.brackets.begin
# ^^^^^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ punctuation.section.brackets.end
# ^ punctuation.section.brackets.begin
# ^^^^^^^ entity.name.command-line-option
# ^^^^^ variable.parameter
# ^ punctuation.section.brackets.end
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
[-u | --set-upstream] [-o <string> | --push-option=<string>]
# ^ punctuation.section.brackets.begin
# ^^ entity.name.command-line-option
# ^ keyword.operator.logical
# ^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.command-line-option
[--force-with-lease[=<refname>[:<expect>]]]
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.section.brackets.begin
# ^ keyword.operator
# ^^^^^^^ variable.parameter
# ^ punctuation.section.brackets.begin
# ^^^^^^ variable.parameter
# ^^^ punctuation.section.brackets.end
example --system [options]
# ^^^^^^^^ entity.name
COMMON OPTIONS
[--quiet] [--debug] [--help|-h] [--version] [--conf FILE]
/* According to POSIX.1-2001, POSIX.1-2008 */
# ^^ source.c comment.block punctuation.definition.comment
#include <sys/select.h>
# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
struct timeval {
# ^^^^^^ source.c storage.type
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
DESCRIPTION
example does something useful in relation to the command line options
and configuration information in /etc/example.conf.
OPTIONS
--conf FILE
# ^^^^^^ entity.name.command-line-option
#^^^^^^ - variable - entity - markup
# ^^^^ variable.parameter
Use FILE instead of /etc/example.conf.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable - entity
--disabled-login
Do not run passwd to set the password. The user won't be able
to use her account until the password is set.
--disabled-password
Like --disabled-login, but logins are still possible (for exam-
# ^^^^^^^^^^^^^^^^ entity.name
#^^^^^^^^^^^^^^^^^^ - entity - variable - markup
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - entity - variable - markup
ple using SSH RSA keys) but not using password authentication.
--help Display brief instructions.
# ^^^^^^ entity.name.command-line-option
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - variable.parameter
--home DIR
# ^^^^^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ - variable - entity - markup
Use DIR as the user's home directory, rather than the default
specified by the configuration file. If the directory does not
exist, it is created and skeleton files are copied.
--[no-]signed, --signed=(true|false|if-asked)
# ^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^^^^^^^ entity.name.command-line-option
# ^ keyword.operator
# ^ - variable
# ^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^^^^ variable.parameter
# ^ - variable
--no-recurse-submodules, --recurse-submodules=check|on-demand|only|no
# ^^^^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^^^^^^^^^^^^^^^^^^^ entity.name.command-line-option
# ^ keyword.operator
# ^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^^^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^^^ variable.parameter
# ^ keyword.operator.logical
# ^^ variable.parameter
May be used to make sure all submodule commits used by the
-c, -C NUM, --context[=NUM]
# ^^ entity.name.command-line-option
# ^ punctuation.separator
# ^^ entity.name.command-line-option
# ^^^ variable.parameter
# ^ punctuation.separator
# ^^^^^^^^^ entity.name.command-line-option
# ^^^^^^^ - entity.name
# ^ keyword.operator
# ^^^ variable.parameter
# ^^ - variable
output NUM (default 3) lines of copied context
EXAMPLE
#include <stdio.h>
# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
(This is not C code.)
# ^^^^^^^^^^^^^^^^^^^^^^ - source.c
struct timeval {
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
# ^ source.c punctuation.terminator
The corresponding argument for pselect() has the following type:
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c
#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
EPOLLHUP | EPOLLERR)
# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end
BIN
View File
Binary file not shown.
Vendored Submodule
+1
Submodule assets/themes/Coldark added at b4a1c74d8d
+8 -6
View File
@@ -39,13 +39,13 @@
### 自動ページング ### 自動ページング
出力が1つの画面に対して大きすぎる場合、`bat` は自身の出力を `less` にパイプで繋げることが可能です。 出力が1つの画面に対して大きすぎる場合、`bat` は自身の出力をページャー(例えば `less`) にパイプで繋げす。
### ファイルの連結 ### ファイルの連結
あなたはさらにファイルを連結させるために使うことも可能です:wink:。 あなたはさらにファイルを連結させるために使うことも可能です:wink:。
`bat` は非対話型のターミナルを検出すると、 `bat` は非対話型のターミナルを検出すると(すなわち他のプロセスにパイプしたりファイル出力していると)
いつでも `cat` の完全互換として振る舞い、 `bat` `cat` の完全互換として振る舞い、
プレーンなファイルを表示します。 プレーンなファイルを表示します。
## 使い方 ## 使い方
@@ -62,7 +62,9 @@
> bat src/*.rs > bat src/*.rs
``` ```
標準入力から自動的に構文を決定させたい場合 標準入力から自動的に構文を決定させたい場合(ハイライトされるのは、
たいていは `#!/bin/sh` のようなシバンを利用して、
ファイルの一行目から構文を決定できる場合のみです)
```bash ```bash
> curl -s https://sh.rustup.rs | bat > curl -s https://sh.rustup.rs | bat
@@ -152,7 +154,7 @@ man 2 select
``` ```
フォーマットの問題が発生した場合は フォーマットの問題が発生した場合は
`MANROFFOPT = "-c"` を設定する必要もあります。 `MANROFFOPT="-c"` を設定する必要もあります。
これを新しいコマンドにバンドルしたい場合は [`batman`](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md) も使用できます。 これを新しいコマンドにバンドルしたい場合は [`batman`](https://github.com/eth-p/bat-extras/blob/master/doc/batman.md) も使用できます。
@@ -189,7 +191,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、 batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
次の方法でインストールします: 次の方法でインストールします:
```bash ```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
``` ```
### On Alpine Linux ### On Alpine Linux
+1 -1
View File
@@ -170,7 +170,7 @@ apt install bat
만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다: 만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
```bash ```bash
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.17.1_amd64.deb # adapt version number and architecture
``` ```
### On Alpine Linux ### On Alpine Linux
+1 -1
View File
@@ -185,7 +185,7 @@ ln -s /usr/bin/batcat ~/.local/bin/bat
[release page](https://github.com/sharkdp/bat/releases) и установить так: [release page](https://github.com/sharkdp/bat/releases) и установить так:
```bash ```bash
sudo dpkg -i bat_0.16.0_amd64.deb # измените архитектуру и версию sudo dpkg -i bat_0.17.1_amd64.deb # измените архитектуру и версию
``` ```
### Alpine Linux ### Alpine Linux
+15 -6
View File
@@ -1,10 +1,12 @@
## Syntax Highlighting in bat ## Adding new builtin languages for syntax highlighting
`bat` uses the [syntect](https://github.com/trishume/syntect) library to highlight source Should you find that a particular syntax is not available within `bat` and think it should be included in `bat` by default, you can follow the instructions outlined below.
`bat` uses the excellent [syntect](https://github.com/trishume/syntect) library to highlight source
code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions
in the `.sublime-syntax` format. in the `.sublime-syntax` format.
In order to add new syntaxes to `bat`, follow these steps: **Important:** Before proceeding, verify that the syntax you wish to add meets the [criteria for inclusion](#Criteria-for-inclusion-of-new-syntaxes).
1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository 1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository
which can be included as a submodule (under `assets/syntaxes`). which can be included as a submodule (under `assets/syntaxes`).
@@ -13,13 +15,15 @@ In order to add new syntaxes to `bat`, follow these steps:
Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* -> Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* ->
*New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder. *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
3. Run the `create.sh` script. It calls `bat cache --build` to parse all available 3. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available
`.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder). `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the 4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
`bat` binary. `bat` binary.
5. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin` 5. Use `bat --list-languages` to check if the new languages are available.
6. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
file. A new binary cache file will be created once before every new release of `bat`. file. A new binary cache file will be created once before every new release of `bat`.
### Troubleshooting ### Troubleshooting
@@ -27,15 +31,20 @@ In order to add new syntaxes to `bat`, follow these steps:
Make sure that the local cache does not interfere with the internally stored syntaxes and Make sure that the local cache does not interfere with the internally stored syntaxes and
themes (`bat cache --clear`). themes (`bat cache --clear`).
## Criteria for inclusion of new syntaxes
* More than 10,000 downloads on packagecontrol.io/
### Manual modifications ### Manual modifications
The following files have been manually modified after converting from a `.tmLanguage` file: The following files have been manually modified after converting from a `.tmLanguage` file:
* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types. * `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
* `Dart.sublime-syntax` => removed `#regex.dart` include. * `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types. * `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
* `Org mode.sublime-syntax` => removed `task` file type. * `Org mode.sublime-syntax` => removed `task` file type.
* `SML.sublime_syntax` => removed `ml` file type. * `SML.sublime_syntax` => removed `ml` file type.
* `Robot.sublime_syntax` => changed name to "Robot Framework"
### Non-submodule additions ### Non-submodule additions
+1 -1
View File
@@ -45,7 +45,7 @@
showguides="true" showguides="true"
inkscape:guide-bbox="true" /> inkscape:guide-bbox="true" />
<rect <rect
style="opacity:1;fill:#f2f2f2;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.14294769px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" style="opacity:0.5;fill:#e5e5e5;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.14294769px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
id="rect1929" id="rect1929"
width="1000" width="1000"
height="286.64285" height="286.64285"

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

+18 -12
View File
@@ -169,9 +169,8 @@ impl App {
|| match self.matches.value_of("color") { || match self.matches.value_of("color") {
Some("always") => true, Some("always") => true,
Some("never") => false, Some("never") => false,
Some("auto") | _ => { Some("auto") => env::var_os("NO_COLOR").is_none() && self.interactive_output,
env::var_os("NO_COLOR").is_none() && self.interactive_output _ => unreachable!("other values for --color are not allowed"),
}
}, },
paging_mode, paging_mode,
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize), term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
@@ -226,17 +225,14 @@ impl App {
style_components, style_components,
syntax_mapping, syntax_mapping,
pager: self.matches.value_of("pager"), pager: self.matches.value_of("pager"),
use_italic_text: match self.matches.value_of("italic-text") { use_italic_text: self.matches.value_of("italic-text") == Some("always"),
Some("always") => true,
_ => false,
},
highlighted_lines: self highlighted_lines: self
.matches .matches
.values_of("highlight-line") .values_of("highlight-line")
.map(|ws| ws.map(LineRange::from).collect()) .map(|ws| ws.map(LineRange::from).collect())
.transpose()? .transpose()?
.map(LineRanges::from) .map(LineRanges::from)
.map(|lr| HighlightedLineRanges(lr)) .map(HighlightedLineRanges)
.unwrap_or_default(), .unwrap_or_default(),
}) })
} }
@@ -288,8 +284,8 @@ impl App {
fn style_components(&self) -> Result<StyleComponents> { fn style_components(&self) -> Result<StyleComponents> {
let matches = &self.matches; let matches = &self.matches;
Ok(StyleComponents( let mut styled_components =
if matches.value_of("decorations") == Some("never") { StyleComponents(if matches.value_of("decorations") == Some("never") {
HashSet::new() HashSet::new()
} else if matches.is_present("number") { } else if matches.is_present("number") {
[StyleComponent::LineNumbers].iter().cloned().collect() [StyleComponent::LineNumbers].iter().cloned().collect()
@@ -323,7 +319,17 @@ impl App {
acc.extend(components.iter().cloned()); acc.extend(components.iter().cloned());
acc acc
}) })
}, });
))
// If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
use ansi_term::Colour::Yellow;
eprintln!(
"{}: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.",
Yellow.paint("[bat warning]"),
);
}
Ok(styled_components)
} }
} }
+7 -2
View File
@@ -24,6 +24,10 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
"A cat(1) clone with wings.\n\n\ "A cat(1) clone with wings.\n\n\
Use '--help' instead of '-h' to see a more detailed version of the help text.", Use '--help' instead of '-h' to see a more detailed version of the help text.",
) )
.after_help(
"Note: `bat -h` prints a short and concise overview while `bat --help` gives all \
details.",
)
.long_about("A cat(1) clone with syntax highlighting and Git integration.") .long_about("A cat(1) clone with syntax highlighting and Git integration.")
.arg( .arg(
Arg::with_name("FILE") Arg::with_name("FILE")
@@ -363,7 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.validator(|val| { .validator(|val| {
let mut invalid_vals = val.split(',').filter(|style| { let mut invalid_vals = val.split(',').filter(|style| {
!&[ !&[
"auto", "full", "plain", "header", "grid", "numbers", "snip", "auto", "full", "plain", "header", "grid", "rule", "numbers", "snip",
#[cfg(feature = "git")] #[cfg(feature = "git")]
"changes", "changes",
] ]
@@ -378,7 +382,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
}) })
.help( .help(
"Comma-separated list of style elements to display \ "Comma-separated list of style elements to display \
(*auto*, full, plain, changes, header, grid, numbers, snip).", (*auto*, full, plain, changes, header, grid, rule, numbers, snip).",
) )
.long_help( .long_help(
"Configure which elements (line numbers, file headers, grid \ "Configure which elements (line numbers, file headers, grid \
@@ -396,6 +400,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
* header: show filenames before the content.\n \ * header: show filenames before the content.\n \
* grid: vertical/horizontal lines to separate side bar\n \ * grid: vertical/horizontal lines to separate side bar\n \
and the header from the content.\n \ and the header from the content.\n \
* rule: horizontal lines to delimit files.\n \
* numbers: show line numbers in the side bar.\n \ * numbers: show line numbers in the side bar.\n \
* snip: draw separation lines between distinct line ranges.", * snip: draw separation lines between distinct line ranges.",
), ),
+2 -3
View File
@@ -44,8 +44,7 @@ pub fn generate_config_file() -> bat::error::Result<()> {
} }
} }
let default_config = let default_config = r#"# This is `bat`s configuration file. Each line either contains a comment or
r#"# This is `bat`s configuration file. Each line either contains a comment or
# a command-line option that you want to pass to `bat` by default. You can # a command-line option that you want to pass to `bat` by default. You can
# run `bat --help` to get a list of all possible configuration options. # run `bat --help` to get a list of all possible configuration options.
@@ -86,7 +85,7 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
.ok() .ok()
.map(|content| get_args_from_str(&content)) .map(|content| get_args_from_str(&content))
.transpose()? .transpose()?
.unwrap_or_else(|| vec![])) .unwrap_or_else(Vec::new))
} }
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> { pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
+8
View File
@@ -205,6 +205,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
writeln!(stdout, "{}", theme)?; writeln!(stdout, "{}", theme)?;
} }
} }
writeln!(
stdout,
"Further themes can be installed to '{}', \
and are added to the cache with `bat cache --build`. \
For more information, see:\n\n \
https://github.com/sharkdp/bat#adding-new-themes",
config_file().join("themes").to_string_lossy()
)?;
Ok(()) Ok(())
} }
+5 -2
View File
@@ -54,7 +54,10 @@ impl<'b> Controller<'b> {
paging_mode = PagingMode::Never; paging_mode = PagingMode::Never;
} }
} }
output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
let wrapping_mode = self.config.wrapping_mode;
output_type = OutputType::from_mode(paging_mode, wrapping_mode, self.config.pager)?;
} }
#[cfg(not(feature = "paging"))] #[cfg(not(feature = "paging"))]
@@ -144,7 +147,7 @@ impl<'b> Controller<'b> {
Ok(no_errors) Ok(no_errors)
} }
fn print_file<'a>( fn print_file(
&self, &self,
printer: &mut dyn Printer, printer: &mut dyn Printer,
writer: &mut dyn Write, writer: &mut dyn Write,
+4
View File
@@ -20,6 +20,10 @@ error_chain! {
description("unknown syntax"), description("unknown syntax"),
display("unknown syntax: '{}'", name) display("unknown syntax: '{}'", name)
} }
InvalidPagerValueBat {
description("invalid value `bat` for pager property"),
display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")
}
} }
} }
+2 -3
View File
@@ -143,9 +143,8 @@ impl<'a> Input<'a> {
} }
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self { pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
match provided_name { if let Some(name) = provided_name {
Some(name) => self.description.name = name.to_string_lossy().to_string(), self.description.name = name.to_string_lossy().to_string()
None => {}
} }
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned()); self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
+31 -8
View File
@@ -7,6 +7,15 @@ use crate::error::*;
use crate::less::retrieve_less_version; use crate::less::retrieve_less_version;
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
use crate::paging::PagingMode; use crate::paging::PagingMode;
#[cfg(feature = "paging")]
use crate::wrapping::WrappingMode;
#[cfg(feature = "paging")]
#[derive(Debug, PartialEq)]
enum SingleScreenAction {
Quit,
Nothing,
}
#[derive(Debug)] #[derive(Debug)]
pub enum OutputType { pub enum OutputType {
@@ -17,18 +26,28 @@ pub enum OutputType {
impl OutputType { impl OutputType {
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
pub fn from_mode(mode: PagingMode, pager: Option<&str>) -> Result<Self> { pub fn from_mode(
paging_mode: PagingMode,
wrapping_mode: WrappingMode,
pager: Option<&str>,
) -> Result<Self> {
use self::PagingMode::*; use self::PagingMode::*;
Ok(match mode { Ok(match paging_mode {
Always => OutputType::try_pager(false, pager)?, Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?,
QuitIfOneScreen => OutputType::try_pager(true, pager)?, QuitIfOneScreen => {
OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?
}
_ => OutputType::stdout(), _ => OutputType::stdout(),
}) })
} }
/// Try to launch the pager. Fall back to stdout in case of errors. /// Try to launch the pager. Fall back to stdout in case of errors.
#[cfg(feature = "paging")] #[cfg(feature = "paging")]
fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> { fn try_pager(
single_screen_action: SingleScreenAction,
wrapping_mode: WrappingMode,
pager_from_config: Option<&str>,
) -> Result<Self> {
use std::env; use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::path::PathBuf; use std::path::PathBuf;
@@ -66,10 +85,10 @@ impl OutputType {
match pagerflags.split_first() { match pagerflags.split_first() {
Some((pager_name, args)) => { Some((pager_name, args)) => {
let mut pager_path = PathBuf::from(pager_name); let pager_path = PathBuf::from(pager_name);
if pager_path.file_stem() == Some(&OsString::from("bat")) { if pager_path.file_stem() == Some(&OsString::from("bat")) {
pager_path = PathBuf::from("less"); return Err(ErrorKind::InvalidPagerValueBat.into());
} }
let is_less = pager_path.file_stem() == Some(&OsString::from("less")); let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
@@ -78,10 +97,14 @@ impl OutputType {
let mut p = Command::new(&pager_path); let mut p = Command::new(&pager_path);
if args.is_empty() || replace_arguments_to_less { if args.is_empty() || replace_arguments_to_less {
p.arg("--RAW-CONTROL-CHARS"); p.arg("--RAW-CONTROL-CHARS");
if quit_if_one_screen { if single_screen_action == SingleScreenAction::Quit {
p.arg("--quit-if-one-screen"); p.arg("--quit-if-one-screen");
} }
if wrapping_mode == WrappingMode::NoWrapping {
p.arg("--chop-long-lines");
}
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support. // versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
// //
+11 -1
View File
@@ -23,6 +23,7 @@ struct ActiveStyleComponents {
header: bool, header: bool,
vcs_modification_markers: bool, vcs_modification_markers: bool,
grid: bool, grid: bool,
rule: bool,
line_numbers: bool, line_numbers: bool,
snip: bool, snip: bool,
} }
@@ -179,6 +180,12 @@ impl<'a> PrettyPrinter<'a> {
self self
} }
/// Whether to paint a horizontal rule to delimit files
pub fn rule(&mut self, yes: bool) -> &mut Self {
self.active_style_components.rule = yes;
self
}
/// Whether to show modification markers for VCS changes. This has no effect if /// Whether to show modification markers for VCS changes. This has no effect if
/// the `git` feature is not activated. /// the `git` feature is not activated.
#[cfg_attr( #[cfg_attr(
@@ -285,6 +292,9 @@ impl<'a> PrettyPrinter<'a> {
if self.active_style_components.grid { if self.active_style_components.grid {
style_components.push(StyleComponent::Grid); style_components.push(StyleComponent::Grid);
} }
if self.active_style_components.rule {
style_components.push(StyleComponent::Rule);
}
if self.active_style_components.header { if self.active_style_components.header {
style_components.push(StyleComponent::Header); style_components.push(StyleComponent::Header);
} }
@@ -328,7 +338,7 @@ impl<'a> Input<'a> {
/// A new input from bytes. /// A new input from bytes.
pub fn from_bytes(bytes: &'a [u8]) -> Self { pub fn from_bytes(bytes: &'a [u8]) -> Self {
Input::from_reader(bytes).into() Input::from_reader(bytes)
} }
/// A new input from STDIN. /// A new input from STDIN.
+19 -7
View File
@@ -200,13 +200,18 @@ impl<'a> InteractivePrinter<'a> {
}) })
} }
fn print_horizontal_line_term(&mut self, handle: &mut dyn Write, style: Style) -> Result<()> {
writeln!(
handle,
"{}",
style.paint("".repeat(self.config.term_width))
)?;
Ok(())
}
fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> { fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
if self.panel_width == 0 { if self.panel_width == 0 {
writeln!( self.print_horizontal_line_term(handle, self.colors.grid)?;
handle,
"{}",
self.colors.grid.paint("".repeat(self.config.term_width))
)?;
} else { } else {
let hline = "".repeat(self.config.term_width - (self.panel_width + 1)); let hline = "".repeat(self.config.term_width - (self.panel_width + 1));
let hline = format!("{}{}{}", "".repeat(self.panel_width), grid_char, hline); let hline = format!("{}{}{}", "".repeat(self.panel_width), grid_char, hline);
@@ -251,6 +256,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
input: &OpenedInput, input: &OpenedInput,
add_header_padding: bool, add_header_padding: bool,
) -> Result<()> { ) -> Result<()> {
if add_header_padding && self.config.style_components.rule() {
self.print_horizontal_line_term(handle, self.colors.rule)?;
}
if !self.config.style_components.header() { if !self.config.style_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable { if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
writeln!( writeln!(
@@ -279,7 +288,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
.paint(if self.panel_width > 0 { "" } else { "" }), .paint(if self.panel_width > 0 { "" } else { "" }),
)?; )?;
} else { } else {
if add_header_padding { // Only pad space between files, if we haven't already drawn a horizontal rule
if add_header_padding && !self.config.style_components.rule() {
writeln!(handle)?; writeln!(handle)?;
} }
write!(handle, "{}", " ".repeat(self.panel_width))?; write!(handle, "{}", " ".repeat(self.panel_width))?;
@@ -301,7 +311,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
description description
.kind() .kind()
.map(|kind| format!("{}: ", kind)) .map(|kind| format!("{}: ", kind))
.unwrap_or("".into()), .unwrap_or_else(|| "".into()),
self.colors.filename.paint(description.title()), self.colors.filename.paint(description.title()),
mode mode
)?; )?;
@@ -603,6 +613,7 @@ const DEFAULT_GUTTER_COLOR: u8 = 238;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct Colors { pub struct Colors {
pub grid: Style, pub grid: Style,
pub rule: Style,
pub filename: Style, pub filename: Style,
pub git_added: Style, pub git_added: Style,
pub git_removed: Style, pub git_removed: Style,
@@ -624,6 +635,7 @@ impl Colors {
Colors { Colors {
grid: gutter_color.normal(), grid: gutter_color.normal(),
rule: gutter_color.normal(),
filename: Style::new().bold(), filename: Style::new().bold(),
git_added: Green.normal(), git_added: Green.normal(),
git_removed: Red.normal(), git_removed: Red.normal(),
+7
View File
@@ -9,6 +9,7 @@ pub enum StyleComponent {
#[cfg(feature = "git")] #[cfg(feature = "git")]
Changes, Changes,
Grid, Grid,
Rule,
Header, Header,
LineNumbers, LineNumbers,
Snip, Snip,
@@ -29,6 +30,7 @@ impl StyleComponent {
#[cfg(feature = "git")] #[cfg(feature = "git")]
StyleComponent::Changes => &[StyleComponent::Changes], StyleComponent::Changes => &[StyleComponent::Changes],
StyleComponent::Grid => &[StyleComponent::Grid], StyleComponent::Grid => &[StyleComponent::Grid],
StyleComponent::Rule => &[StyleComponent::Rule],
StyleComponent::Header => &[StyleComponent::Header], StyleComponent::Header => &[StyleComponent::Header],
StyleComponent::LineNumbers => &[StyleComponent::LineNumbers], StyleComponent::LineNumbers => &[StyleComponent::LineNumbers],
StyleComponent::Snip => &[StyleComponent::Snip], StyleComponent::Snip => &[StyleComponent::Snip],
@@ -54,6 +56,7 @@ impl FromStr for StyleComponent {
#[cfg(feature = "git")] #[cfg(feature = "git")]
"changes" => Ok(StyleComponent::Changes), "changes" => Ok(StyleComponent::Changes),
"grid" => Ok(StyleComponent::Grid), "grid" => Ok(StyleComponent::Grid),
"rule" => Ok(StyleComponent::Rule),
"header" => Ok(StyleComponent::Header), "header" => Ok(StyleComponent::Header),
"numbers" => Ok(StyleComponent::LineNumbers), "numbers" => Ok(StyleComponent::LineNumbers),
"snip" => Ok(StyleComponent::Snip), "snip" => Ok(StyleComponent::Snip),
@@ -81,6 +84,10 @@ impl StyleComponents {
self.0.contains(&StyleComponent::Grid) self.0.contains(&StyleComponent::Grid)
} }
pub fn rule(&self) -> bool {
self.0.contains(&StyleComponent::Rule)
}
pub fn header(&self) -> bool { pub fn header(&self) -> bool {
self.0.contains(&StyleComponent::Header) self.0.contains(&StyleComponent::Header)
} }
+2 -4
View File
@@ -1,10 +1,8 @@
# force LF EOLs for test fixtures # force LF EOLs for test fixtures
examples/** text=auto eol=lf examples/** text=auto eol=lf
snapshots/** text=auto eol=lf snapshots/** text=auto eol=lf
syntax-tests/source/** text=auto eol=lf
# BAT/CMD files always need CRLF EOLs syntax-tests/highlighted/** text=auto eol=lf
*.[Bb][Aa][Tt] text eol=crlf
*.[Cc][Mm][Dd] text eol=crlf
examples/* linguist-vendored examples/* linguist-vendored
snapshots/* linguist-vendored snapshots/* linguist-vendored
+4
View File
@@ -1,7 +1,9 @@
use bat::assets::HighlightingAssets; use bat::assets::HighlightingAssets;
/// This test ensures that we are not accidentally removing themes due to submodule updates. /// This test ensures that we are not accidentally removing themes due to submodule updates.
/// It is 'ignore'd by default because it requires themes.bin to be up-to-date.
#[test] #[test]
#[ignore]
fn all_themes_are_present() { fn all_themes_are_present() {
let assets = HighlightingAssets::from_binary(); let assets = HighlightingAssets::from_binary();
@@ -12,6 +14,8 @@ fn all_themes_are_present() {
themes, themes,
vec![ vec![
"1337", "1337",
"Coldark-Cold",
"Coldark-Dark",
"DarkNeon", "DarkNeon",
"Dracula", "Dracula",
"GitHub", "GitHub",
Vendored Regular → Executable
+3 -1
View File
@@ -1,4 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
if ! which hyperfine > /dev/null 2>&1; then if ! which hyperfine > /dev/null 2>&1; then
echo "'hyperfine' does not seem to be installed." echo "'hyperfine' does not seem to be installed."
Vendored Regular → Executable
+3 -1
View File
@@ -1,4 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")"
if ! which hyperfine > /dev/null 2>&1; then if ! which hyperfine > /dev/null 2>&1; then
echo "'hyperfine' does not seem to be installed." echo "'hyperfine' does not seem to be installed."
+64
View File
@@ -405,6 +405,16 @@ fn pager_disable() {
.stdout(predicate::eq("hello world\n").normalize()); .stdout(predicate::eq("hello world\n").normalize());
} }
#[test]
fn pager_value_bat() {
bat()
.arg("--pager=bat")
.arg("--paging=always")
.arg("test.txt")
.assert()
.failure();
}
#[test] #[test]
fn alias_pager_disable() { fn alias_pager_disable() {
bat() bat()
@@ -570,6 +580,18 @@ fn empty_file_leads_to_empty_output_with_grid_enabled() {
.stdout(""); .stdout("");
} }
#[test]
fn empty_file_leads_to_empty_output_with_rule_enabled() {
bat()
.arg("empty.txt")
.arg("--style=rule")
.arg("--decorations=always")
.arg("--terminal-width=80")
.assert()
.success()
.stdout("");
}
#[test] #[test]
fn filename_basic() { fn filename_basic() {
bat() bat()
@@ -668,6 +690,48 @@ fn header_padding() {
.stderr(""); .stderr("");
} }
#[test]
fn header_padding_rule() {
bat()
.arg("--decorations=always")
.arg("--style=header,rule")
.arg("--terminal-width=80")
.arg("test.txt")
.arg("single-line.txt")
.assert()
.stdout(
"File: test.txt
hello world
File: single-line.txt
Single Line
",
)
.stderr("");
}
#[test]
fn grid_overrides_rule() {
bat()
.arg("--decorations=always")
.arg("--style=grid,rule")
.arg("--terminal-width=80")
.arg("test.txt")
.arg("single-line.txt")
.assert()
.stdout(
"\
hello world
Single Line
",
)
.stderr("\x1b[33m[bat warning]\x1b[0m: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.\n");
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[test] #[test]
fn file_with_invalid_utf8_filename() { fn file_with_invalid_utf8_filename() {
+10
View File
@@ -19,17 +19,27 @@ snapshot_tests! {
grid: "grid", grid: "grid",
header: "header", header: "header",
numbers: "numbers", numbers: "numbers",
rule: "rule",
changes_grid: "changes,grid", changes_grid: "changes,grid",
changes_header: "changes,header", changes_header: "changes,header",
changes_numbers: "changes,numbers", changes_numbers: "changes,numbers",
changes_rule: "changes,rule",
grid_header: "grid,header", grid_header: "grid,header",
grid_numbers: "grid,numbers", grid_numbers: "grid,numbers",
grid_rule: "grid,rule",
header_numbers: "header,numbers", header_numbers: "header,numbers",
header_rule: "header,rule",
changes_grid_header: "changes,grid,header", changes_grid_header: "changes,grid,header",
changes_grid_numbers: "changes,grid,numbers", changes_grid_numbers: "changes,grid,numbers",
changes_grid_rule: "changes,grid,rule",
changes_header_numbers: "changes,header,numbers", changes_header_numbers: "changes,header,numbers",
changes_header_rule: "changes,header,rule",
grid_header_numbers: "grid,header,numbers", grid_header_numbers: "grid,header,numbers",
grid_header_rule: "grid,header,rule",
header_numbers_rule: "header,numbers,rule",
changes_grid_header_numbers: "changes,grid,header,numbers", changes_grid_header_numbers: "changes,grid,header,numbers",
changes_grid_header_rule: "changes,grid,header,rule",
changes_grid_header_numbers_rule: "changes,grid,header,numbers,rule",
full: "full", full: "full",
plain: "plain", plain: "plain",
} }
+1 -1
View File
@@ -7,7 +7,7 @@ import shutil
def generate_snapshots(): def generate_snapshots():
single_styles = ["changes", "grid", "header", "numbers"] single_styles = ["changes", "grid", "header", "numbers", "rule"]
collective_styles = ["full", "plain"] collective_styles = ["full", "plain"]
for num in range(len(single_styles)): for num in range(len(single_styles)):
@@ -0,0 +1,26 @@
───────┬────────────────────────────────────────────────────────────────────────
│ File: sample.rs
───────┼────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: ""#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 + │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
───────┴────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,26 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ File: sample.rs
──┼─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle {
│ width: u32,
│ height: u32,
│ }
_ │ fn main() {
│ let rect1 = Rectangle { width: 30, height: 50 };
│ println!(
~ │ "The perimeter of the rectangle is {} pixels.",
~ │ perimeter(&rect1)
│ );
+ │ println!(r#"This line contains invalid utf8: ""#;
│ }
│ fn area(rectangle: &Rectangle) -> u32 {
│ rectangle.width * rectangle.height
│ }
+ │
+ │ fn perimeter(rectangle: &Rectangle) -> u32 {
+ │ (rectangle.width + rectangle.height) * 2
+ │ }
──┴─────────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,24 @@
───────┬────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 _ │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 ~ │ "The perimeter of the rectangle is {} pixels.",
11 ~ │ perimeter(&rect1)
12 │ );
13 + │ println!(r#"This line contains invalid utf8: ""#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 + │
20 + │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 + │ (rectangle.width + rectangle.height) * 2
22 + │ }
───────┴────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,24 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle {
│ width: u32,
│ height: u32,
│ }
_ │ fn main() {
│ let rect1 = Rectangle { width: 30, height: 50 };
│ println!(
~ │ "The perimeter of the rectangle is {} pixels.",
~ │ perimeter(&rect1)
│ );
+ │ println!(r#"This line contains invalid utf8: ""#;
│ }
│ fn area(rectangle: &Rectangle) -> u32 {
│ rectangle.width * rectangle.height
│ }
+ │
+ │ fn perimeter(rectangle: &Rectangle) -> u32 {
+ │ (rectangle.width + rectangle.height) * 2
+ │ }
──┴─────────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,23 @@
File: sample.rs
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 _ fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 ~ "The perimeter of the rectangle is {} pixels.",
11 ~ perimeter(&rect1)
12 );
13 + println!(r#"This line contains invalid utf8: ""#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19 +
20 + fn perimeter(rectangle: &Rectangle) -> u32 {
21 + (rectangle.width + rectangle.height) * 2
22 + }
@@ -0,0 +1,23 @@
File: sample.rs
struct Rectangle {
width: u32,
height: u32,
}
_ fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
~ "The perimeter of the rectangle is {} pixels.",
~ perimeter(&rect1)
);
+ println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
+
+ fn perimeter(rectangle: &Rectangle) -> u32 {
+ (rectangle.width + rectangle.height) * 2
+ }
@@ -0,0 +1,22 @@
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 _ fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 ~ "The perimeter of the rectangle is {} pixels.",
11 ~ perimeter(&rect1)
12 );
13 + println!(r#"This line contains invalid utf8: ""#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19 +
20 + fn perimeter(rectangle: &Rectangle) -> u32 {
21 + (rectangle.width + rectangle.height) * 2
22 + }
@@ -0,0 +1,22 @@
struct Rectangle {
width: u32,
height: u32,
}
_ fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
~ "The perimeter of the rectangle is {} pixels.",
~ perimeter(&rect1)
);
+ println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
+
+ fn perimeter(rectangle: &Rectangle) -> u32 {
+ (rectangle.width + rectangle.height) * 2
+ }
@@ -0,0 +1,26 @@
─────┬──────────────────────────────────────────────────────────────────────────
│ File: sample.rs
─────┼──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 │ "The perimeter of the rectangle is {} pixels.",
11 │ perimeter(&rect1)
12 │ );
13 │ println!(r#"This line contains invalid utf8: ""#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 │ (rectangle.width + rectangle.height) * 2
22 │ }
─────┴──────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,26 @@
────────────────────────────────────────────────────────────────────────────────
File: sample.rs
────────────────────────────────────────────────────────────────────────────────
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
────────────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,24 @@
─────┬──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle {
2 │ width: u32,
3 │ height: u32,
4 │ }
5 │
6 │ fn main() {
7 │ let rect1 = Rectangle { width: 30, height: 50 };
8 │
9 │ println!(
10 │ "The perimeter of the rectangle is {} pixels.",
11 │ perimeter(&rect1)
12 │ );
13 │ println!(r#"This line contains invalid utf8: ""#;
14 │ }
15 │
16 │ fn area(rectangle: &Rectangle) -> u32 {
17 │ rectangle.width * rectangle.height
18 │ }
19 │
20 │ fn perimeter(rectangle: &Rectangle) -> u32 {
21 │ (rectangle.width + rectangle.height) * 2
22 │ }
─────┴──────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,24 @@
────────────────────────────────────────────────────────────────────────────────
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
────────────────────────────────────────────────────────────────────────────────
@@ -0,0 +1,23 @@
File: sample.rs
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 "The perimeter of the rectangle is {} pixels.",
11 perimeter(&rect1)
12 );
13 println!(r#"This line contains invalid utf8: ""#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19
20 fn perimeter(rectangle: &Rectangle) -> u32 {
21 (rectangle.width + rectangle.height) * 2
22 }
@@ -0,0 +1,23 @@
File: sample.rs
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
@@ -0,0 +1,22 @@
1 struct Rectangle {
2 width: u32,
3 height: u32,
4 }
5
6 fn main() {
7 let rect1 = Rectangle { width: 30, height: 50 };
8
9 println!(
10 "The perimeter of the rectangle is {} pixels.",
11 perimeter(&rect1)
12 );
13 println!(r#"This line contains invalid utf8: ""#;
14 }
15
16 fn area(rectangle: &Rectangle) -> u32 {
17 rectangle.width * rectangle.height
18 }
19
20 fn perimeter(rectangle: &Rectangle) -> u32 {
21 (rectangle.width + rectangle.height) * 2
22 }
+22
View File
@@ -0,0 +1,22 @@
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The perimeter of the rectangle is {} pixels.",
perimeter(&rect1)
);
println!(r#"This line contains invalid utf8: ""#;
}
fn area(rectangle: &Rectangle) -> u32 {
rectangle.width * rectangle.height
}
fn perimeter(rectangle: &Rectangle) -> u32 {
(rectangle.width + rectangle.height) * 2
}
+35 -6
View File
@@ -16,11 +16,32 @@ BAT_OPTIONS = [
"--italic-text=always", "--italic-text=always",
] ]
SKIP_FILENAMES = [
"LICENSE.md",
"README.md",
"bat_options",
]
def get_options(source):
options = BAT_OPTIONS.copy()
source_dirpath = path.dirname(source)
options_file = path.join(source_dirpath, "bat_options")
try:
with open(options_file, "r") as f:
options.extend(map(lambda x: x.rstrip(), f.readlines()))
except FileNotFoundError:
pass
return options
def create_highlighted_versions(output_basepath): def create_highlighted_versions(output_basepath):
root = os.path.dirname(os.path.abspath(__file__)) root = os.path.dirname(os.path.abspath(__file__))
sources = path.join(root, "source", "*")
for source in glob.glob(path.join(root, "source", "*", "*")): for source in glob.glob(path.join(sources, "*")) + glob.glob(path.join(sources, ".*")):
try: try:
env = os.environ.copy() env = os.environ.copy()
env.pop("PAGER", None) env.pop("PAGER", None)
@@ -31,16 +52,18 @@ def create_highlighted_versions(output_basepath):
env.pop("BAT_TABS", None) env.pop("BAT_TABS", None)
env["COLORTERM"] = "truecolor" # make sure to output 24bit colors env["COLORTERM"] = "truecolor" # make sure to output 24bit colors
bat_output = subprocess.check_output(
["bat"] + BAT_OPTIONS + [source], stderr=subprocess.PIPE, env=env,
)
source_dirname = path.basename(path.dirname(source)) source_dirname = path.basename(path.dirname(source))
source_filename = path.basename(source) source_filename = path.basename(source)
if source_filename == "LICENSE.md": if source_filename in SKIP_FILENAMES:
continue continue
bat_output = subprocess.check_output(
["bat"] + get_options(source) + [source],
stderr=subprocess.PIPE,
env=env,
)
output_dir = path.join(output_basepath, source_dirname) output_dir = path.join(output_basepath, source_dirname)
output_path = path.join(output_dir, source_filename) output_path = path.join(output_dir, source_filename)
@@ -64,6 +87,12 @@ def create_highlighted_versions(output_basepath):
file=sys.stderr, file=sys.stderr,
) )
sys.exit(1) sys.exit(1)
except FileNotFoundError:
print(
"Error: Could not execute 'bat'. Please make sure that the executable "
"is available on the PATH."
)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
@@ -0,0 +1,55 @@
.data
.balign 4
red: .word 0
green: .word 0
blue: .word 0
.text
.global grayscale
.func grayscale
grayscale:
assign:
 /* some comment */
 ldr ip, addr_red
 str r3, [ip]
 ldr ip, addr_green
 ldmfd r13!, {r3}
 str r3, [ip]
 ldr ip, addr_blue
 ldmfd r13!, {r3}
 str r3, [ip]
 stmfd r13!, {r4-r8}
 ldr ip, addr_red
 ldr r3, [ip]
 ldr ip, addr_green
 ldr r4, [ip]
 ldr ip, addr_blue
 ldr r5, [ip] /* another comment */
grayscale_loop:
 ldrb r6, [r1]
 mul r6, r3, r6
 add r1, r1, #1
 ldrb r7, [r1]
 mul r7, r4, r7
 add r1, r1, #1
 ldrb r8, [r1]
 mul r8, r5, r8
 add r1, r1, #1
 add r6, r6, r7
 add r6, r6, r8
 asr r6, r6, #8
 str r6, [r2]
 add r2, r2, #1
 sub r0, r0, #1
 cmp r0, #0
 bne grayscale_loop
 ldmfd r13!, {r4-r8}
 stmfd r13!, {r0-r1}
 bx lr
addr_red: .word red
addr_green: .word green
addr_blue: .word blue
@@ -0,0 +1,36 @@
<html>
<body>
<!-- #include file ="headers\header.inc" -->
<%
For i = 0 To 5
Response.Write("The number is " & i & "<br />")
Next
%>
<%
Response.Write("Hello World!")
%>
<%
Dim x(2,2)
x(0,0)="Volvo"
x(0,1)="BMW"
x(0,2)="Ford"
x(1,0)="Apple"
x(1,1)="Orange"
x(1,2)="Banana"
x(2,0)="Coke"
x(2,1)="Pepsi"
x(2,2)="Sprite"
for i=0 to 2
response.write("<p>")
for j=0 to 2
response.write(x(i,j) & "<br />")
next
response.write("</p>")
next
%>
</body>
</html>
@@ -0,0 +1,75 @@
import flash.events.*;
import flash.events.MouseEvent;
package TestSyntax {
 public class TestSyntax extends flash.display.Sprite {
 public static const TEST_CONSTANT:Number = 33.333;
 var testAttribute:int = 1;
 public namespace TestNamespace;
 TestNamespace function Method2():void { }
 /**
 * Multi-line comment
 */
 override public function set x(value:Number):void
 {
 super.x = Math.round(value);
 }
 /**
 * Actual multi-line comment
 * Takes up multiple lines
 */
 override public function set y(value:Number):void
 {
 super.y = 0;
 }
 public function testFunction() {
 var test:String = 'hello';
 // arrays
 var testArray:Array = ["a", "b", "c", "d"];
 for (var i:uint = 0; i < testArray.length; i++)
 trace(testArray[i]);
 // objects
 var testObject:Object = {foo: 20, bar: 40};
 for (var key:String in testObject) {
 trace(testObject[key]);
 }
 for each (var objectValue:int in testObject) {
 trace(objectValue);
 }
 // dynamic variables
 var testDynamic:*;
 testDynamic = 75;
 testDynamic = "Seventy-five";
 // regex
 var testRegExp:RegExp = /foo-\d+/i;
 // XML
 var testXML:XML =
<employee>
 <firstName>Harold</firstName>
 <lastName>Webster</lastName>
</employee>;
 }
 private function anotherFunc(a:int, arg2:uint, arg3:Function, ... args) {
 }
 [Embed(source="sound1.mp3")] public var soundCls:Class;
 public function SoundAssetExample()
 {
 var mySound:SoundAsset = new soundCls() as SoundAsset;
 var sndChannel:SoundChannel = mySound.play();
 }
 }
}
@@ -0,0 +1,42 @@
# This is a comment
#
ServerRoot ""
Listen 80
LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin you@example.com
<Directory />
 AllowOverride none
 Require all denied
</Directory>
DocumentRoot "/usr/share/apache2/default-site/htdocs"
<Directory "/usr/share/apache2/default-site/htdocs">
 Options Indexes FollowSymLinks
 AllowOverride None
 Require all granted
</Directory>
<Files ".ht*">
 Require all denied
</Files>
ErrorLog "/var/log/apache2/error_log"
LogLevel warn
<IfModule log_config_module>
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
 CustomLog "/var/log/apache2/access_log" common
</IfModule>
<IfModule alias_module>
 ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
</IfModule>
<IfModule mime_module>
 TypesConfig /etc/apache2/mime.types
 AddType application/x-compress .Z
 AddOutputFilter INCLUDES .shtml
</IfModule>
<IfModule proxy_html_module>
Include /etc/apache2/extra/proxy-html.conf
</IfModule>
@@ -0,0 +1,25 @@
-- This is a comment
property defaultClientName : "Mary Smith"
on greetClient(nameOfClient)
 display dialog ("Hello " & nameOfClient & "!")
end greetClient
script testGreet
 greetClient(defaultClientName)
end script
run testGreet
greetClient("Joe Jones")
set myList to {1, "what", 3}
set beginning of myList to 0
set end of myList to "four"
myList
tell application "TextEdit"
 paragraph 1 of document 1
end tell
@@ -0,0 +1,173 @@
= This is the document title
Author McAuthorson <author@author.org>
== Table of Content
:toc:
== Paragraphs
[.lead]
This text will be styled as a lead paragraph with a larger font.
This is a normal paragraph.
 This is a literal paragraph that is offset by one space, 
 it will be rendered in a fixed-width font.
NOTE: This is an admonition paragraph
TIP: This is another admonition paragraph
== Formatted text
*bold text*
_italic text_
*_bold italic text_*
`monospace text`
`*bold monospace*`
`_italic monospace_`
`*_bold and italic monospace_*`
The following word is #highlighted#
The following words are [.small]#small print#
The following word is [.underline]#underlined#
The following word is [.line-through]#line-through#
The following word is [.big]#big#
The following word is printed in ^superscript^
The following word is printed in ~sub-script~
== Include
include::not_existing.adoc[]
== Breaks
Here we have a +
line break.
Below is a horizontal rule.
'''
And below here is a page break.
<<<
== Lists
* This is
* an unordered
* list
** with nested
*** elements
'''
- This is also an
- unordered
- list
'''
. And this is
. an ordered
. list
.. with nested
... elements
'''
//* [*] checked
* [x] also checked
* [ ] not checked
* normal list item
'''
[qanda]
What is this?::
 This is a Q&A
And what is this?:: Also a Q&A
== Links
The following link will be created automatically: https://asciidoctor.org
.An image caption
image::not_existing.jpg[alt text]
.A video caption
video::not_existing.mp4[alt text]
== Source Code
The following word is `monospace`.
....
This is a literal block
where linebreaks are rendered
....
.example.java
[source,java]
----
public class Example { // <1>
 private static boolean isExample = true; // <2>
}
----
<1> This is a callout
<2> This is another callout
== Misc
.A sidebar
****
This will be rendered like a sidebar
****
____
This is a random blockquote
____
[quote, Albert Einstein, 'Scientist']
____
This is not actually something Einstein said
____
// here we have a single line comment
////
and this is a
multiline comment
////
.A Table
[%header]
|===
|Header Column 1 |Header Column 2 |And the last header column
|Cell in col1
|Cell in col2
|Cell in col3
|Cell in col1, row2
|Cell in col2, row2
|Cell in col3, row2
|===
.A Table from CSV
[%header, format=csv]
|===
header col1, header col2, header col3
This,is the first, row
This, is the second, row
|===
@@ -0,0 +1,86 @@
global enlight
section .data
 red dq 0 ; some comment
 green dq 0
 blue dq 0
 data dq 0
 N dd 0
 M dd 0
 change dd 0
 delta db 0
section .text
enlight:
 call assign_arguments
 call set_data
 call make_deltas
 ret
assign_arguments:
 mov qword[red], rdi
 mov qword[green], rsi
 mov qword[blue], rdx
 mov dword[N], ecx
 mov dword[M], r8d
 mov dword[change], r9d
 mov al, byte[rsp + 16]
 mov byte[delta], al
 ret
set_data:
 mov eax, dword[change]
 cmp eax, 1
 jne not_1
 mov rax, qword[red]
 mov qword[data], rax
 ret
not_1:
 cmp eax, 2
 jne not_2
 mov rax, qword[green]
 mov qword[data], rax
 ret
not_2:
 mov rax, qword[blue]
 mov qword[data], rax
 ret
make_deltas:
 mov ecx, dword[N]
 mov eax, dword[M]
 imul ecx, eax
loop_start:
 call make_delta
 loop loop_start
 ret
make_delta:
 mov rax, qword[data]
 add rax, rcx
 dec rax
 mov dl, byte[delta]
 cmp dl, 0
 jl substracting
adding:
 add dl, byte[rax]
 jc adding_overflow
 mov byte[rax], dl
 ret
adding_overflow:
 mov byte[rax], 255 
 ret
substracting:
 mov r9b, dl
 mov dl, 0
 sub dl, r9b
 mov r8b, byte[rax]
 sub r8b, dl
 jc substracting_overflow
 mov byte[rax], r8b
 ret
; another comment
substracting_overflow:
 mov byte[rax], 0
 ret
@@ -0,0 +1,511 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# bat-extras | Copyright (C) 2020 eth-p and contributors | MIT License
#
# Repository: https://github.com/eth-p/bat-extras
# Issues: https://github.com/eth-p/bat-extras/issues
# -----------------------------------------------------------------------------
printc(){
printf "$(sed "$_PRINTC_PATTERN" <<<"$1")" "${@:2}"
}
printc_init(){
case "$1" in
true)_PRINTC_PATTERN="$_PRINTC_PATTERN_ANSI";;
false)_PRINTC_PATTERN="$_PRINTC_PATTERN_PLAIN";;
"[DEFINE]"){
_PRINTC_PATTERN_ANSI=""
_PRINTC_PATTERN_PLAIN=""
local name
local ansi
while read -r name ansi;do
if [[ -z $name && -z $ansi ]]||[[ ${name:0:1} == "#" ]];then
continue
fi
ansi="${ansi/\\/\\\\}"
_PRINTC_PATTERN_PLAIN="${_PRINTC_PATTERN_PLAIN}s/%{$name}//g;"
_PRINTC_PATTERN_ANSI="${_PRINTC_PATTERN_ANSI}s/%{$name}/$ansi/g;"
done
if [ -t 1 ];then
_PRINTC_PATTERN="$_PRINTC_PATTERN_ANSI"
else
_PRINTC_PATTERN="$_PRINTC_PATTERN_PLAIN"
fi
}
esac
}
print_warning(){
printc "%{YELLOW}[%s warning]%{CLEAR}: $1%{CLEAR}\n" "batgrep" "${@:2}" 1>&2
}
print_error(){
printc "%{RED}[%s error]%{CLEAR}: $1%{CLEAR}\n" "batgrep" "${@:2}" 1>&2
}
printc_init "[DEFINE]" <<END
 CLEAR \x1B[0m
 RED \x1B[31m
 GREEN \x1B[32m
 YELLOW \x1B[33m
 BLUE \x1B[34m
 MAGENTA \x1B[35m
 CYAN \x1B[36m
 DEFAULT \x1B[39m
 DIM \x1B[2m
END
is_pager_less(){
[[ "$(pager_name)" == "less" ]]
return $?
}
is_pager_disabled(){
[[ -z "$(pager_name)" ]]
return $?
}
pager_name(){
_detect_pager 1>&2
echo "$_SCRIPT_PAGER_NAME"
}
pager_version(){
_detect_pager 1>&2
echo "$_SCRIPT_PAGER_VERSION"
}
pager_exec(){
if [[ -n $SCRIPT_PAGER_CMD ]];then
"$@"|pager_display
return $?
else
"$@"
return $?
fi
}
pager_display(){
if [[ -n $SCRIPT_PAGER_CMD ]];then
if [[ -n $SCRIPT_PAGER_ARGS ]];then
"${SCRIPT_PAGER_CMD[@]}" "${SCRIPT_PAGER_ARGS[@]}"
return $?
else
"${SCRIPT_PAGER_CMD[@]}"
return $?
fi
else
cat
return $?
fi
}
_detect_pager(){
if [[ $_SCRIPT_PAGER_DETECTED == "true" ]];then return;fi
_SCRIPT_PAGER_DETECTED=true
if [[ -z ${SCRIPT_PAGER_CMD[0]} ]];then
_SCRIPT_PAGER_VERSION=0
_SCRIPT_PAGER_NAME=""
return
fi
local output
local output1
output="$("${SCRIPT_PAGER_CMD[0]}" --version 2>&1)"
output1="$(head -n 1 <<<"$output")"
if [[ $output1 =~ ^less[[:blank:]]([[:digit:]]+) ]];then
_SCRIPT_PAGER_VERSION="${BASH_REMATCH[1]}"
_SCRIPT_PAGER_NAME="less"
else
_SCRIPT_PAGER_VERSION=0
_SCRIPT_PAGER_NAME="$(basename "${SCRIPT_PAGER_CMD[0]}")"
fi
}
_configure_pager(){
SCRIPT_PAGER_CMD=($PAGER)
SCRIPT_PAGER_ARGS=()
if [[ -n ${BAT_PAGER+x} ]];then
SCRIPT_PAGER_CMD=($BAT_PAGER)
SCRIPT_PAGER_ARGS=()
return
fi
if is_pager_less;then
SCRIPT_PAGER_CMD=("${SCRIPT_PAGER_CMD[0]}" -R --quit-if-one-screen)
if [[ "$(pager_version)" -lt 500 ]];then
SCRIPT_PAGER_CMD+=(--no-init)
fi
fi
}
if [[ -t 1 ]];then
_configure_pager
else
SCRIPT_PAGER_CMD=()
SCRIPT_PAGER_ARGS=()
fi
SHIFTOPT_HOOKS=()
setargs(){
_ARGV=("$@")
_ARGV_LAST="$((${#_ARGV[@]}-1))"
_ARGV_INDEX=0
}
shiftopt(){
[[ $_ARGV_INDEX -gt $_ARGV_LAST ]]&&return 1
OPT="${_ARGV[$_ARGV_INDEX]}"
unset OPT_VAL
if [[ $OPT =~ ^--[a-zA-Z0-9_-]+=.* ]];then
OPT_VAL="${OPT#*=}"
OPT="${OPT%%=*}"
fi
((_ARGV_INDEX++))
local hook
for hook in "${SHIFTOPT_HOOKS[@]}";do
if "$hook";then
shiftopt
return $?
fi
done
return 0
}
shiftval(){
if [[ -n ${OPT_VAL+x} ]];then
return 0
fi
if [[ $OPT =~ ^-[[:alpha:]][[:digit:]]{1,}$ ]];then
OPT_VAL="${OPT:2}"
return
fi
OPT_VAL="${_ARGV[$_ARGV_INDEX]}"
((_ARGV_INDEX++))
if [[ $OPT_VAL =~ -.* ]];then
printc "%{RED}%s: '%s' requires a value%{CLEAR}\n" "batgrep" "$ARG"
exit 1
fi
}
setargs "$@"
hook_color(){
SHIFTOPT_HOOKS+=("__shiftopt_hook__color")
__shiftopt_hook__color(){
case "$OPT" in
--no-color)OPT_COLOR=false;;
--color){
case "$OPT_VAL" in
"")OPT_COLOR=true;;
always|true)OPT_COLOR=true;;
never|false)OPT_COLOR=false;;
auto)return 0;;
*)printc "%{RED}%s: '--color' expects value of 'auto', 'always', or 'never'%{CLEAR}\n" "batgrep"
exit 1
esac
};;
*)return 1
esac
printc_init "$OPT_COLOR"
return 0
}
if [[ -z $OPT_COLOR ]];then
if [[ -t 1 ]];then
OPT_COLOR=true
else
OPT_COLOR=false
fi
printc_init "$OPT_COLOR"
fi
}
hook_pager(){
SHIFTOPT_HOOKS+=("__shiftopt_hook__pager")
__shiftopt_hook__pager(){
case "$OPT" in
\
--no-pager)shiftval
SCRIPT_PAGER_CMD=''
;;
--paging){
shiftval
case "$OPT_VAL" in
auto):;;
always):;;
never)SCRIPT_PAGER_CMD='';;
*)printc "%{RED}%s: '--paging' expects value of 'auto', 'always', or 'never'%{CLEAR}\n" "batgrep"
exit 1
esac
};;
\
--pager){
shiftval
{
SCRIPT_PAGER_CMD=($OPT_VAL)
PAGER_ARGS=()
}
};;
*)return 1
esac
}
}
hook_version(){
SHIFTOPT_HOOKS+=("__shiftopt_hook__version")
__shiftopt_hook__version(){
if [[ $OPT == "--version" ]];then
printf "%s %s\n\n%s\n%s\n" \
"batgrep" \
"2020.10.04" \
"Copyright (C) 2019-2020 eth-p | MIT License" \
"https://github.com/eth-p/bat-extras"
exit 0
fi
return 1
}
}
term_width(){
local width="$({ stty size 2>/dev/null||echo "22 80";}|cut -d ' ' -f2)"
if [[ $width -ne 0 ]];then
echo "$width"
else
echo "80"
fi
return 0
}
hook_width(){
SHIFTOPT_HOOKS+=("__shiftopt_hook__width")
__shiftopt_hook__width(){
case "$OPT" in
--terminal-width)shiftval
OPT_TERMINAL_WIDTH="$OPT_VAL"
;;
*)return 1
esac
return 0
}
OPT_TERMINAL_WIDTH="$(term_width)"
}
bat_version(){
"bat" --version|cut -d ' ' -f 2
return
}
version_compare(){
local version="$1"
local compare="$3"
if ! [[ $version =~ \.$ ]];then
version="$version."
fi
if ! [[ $compare =~ \.$ ]];then
compare="$compare."
fi
version_compare__recurse "$version" "$2" "$compare"
return $?
}
version_compare__recurse(){
local version="$1"
local operator="$2"
local compare="$3"
local v_major="${version%%.*}"
local c_major="${compare%%.*}"
local v_minor="${version#*.}"
local c_minor="${compare#*.}"
if [[ -z $v_minor && -z $c_minor ]];then
[ "$v_major" $operator "$c_major" ]
return $?
fi
if [[ -z $v_minor ]];then
v_minor="0."
fi
if [[ -z $c_minor ]];then
c_minor="0."
fi
case "$operator" in
-eq)[[ $v_major -ne $c_major ]]&&return 1;;
-ne)[[ $v_major -ne $c_major ]]&&return 0;;
-ge|-gt)[[ $v_major -lt $c_major ]]&&return 1
[[ $v_major -gt $c_major ]]&&return 0
;;
-le|-lt)[[ $v_major -gt $c_major ]]&&return 1
[[ $v_major -lt $c_major ]]&&return 0
esac
version_compare__recurse "$v_minor" "$operator" "$c_minor"
}
hook_color
hook_pager
hook_version
hook_width
RG_ARGS=()
BAT_ARGS=()
PATTERN=""
FILES=()
OPT_CASE_SENSITIVITY=''
OPT_CONTEXT_BEFORE=2
OPT_CONTEXT_AFTER=2
OPT_FOLLOW=true
OPT_SNIP=""
OPT_HIGHLIGHT=true
OPT_SEARCH_PATTERN=false
OPT_FIXED_STRINGS=false
BAT_STYLE="header,numbers"
if version_compare "$(bat_version)" -gt "0.12";then
OPT_SNIP=",snip"
fi
if [[ -n $RIPGREP_CONFIG_PATH && -e $RIPGREP_CONFIG_PATH ]];then
for arg in $(cat "$RIPGREP_CONFIG_PATH");do
case "$arg" in
--context=*)val="${arg:10}"
OPT_CONTEXT_BEFORE="$val"
OPT_CONTEXT_AFTER="$val"
;;
--before-context=*)val="${arg:17}"
OPT_CONTEXT_BEFORE="$val"
;;
--after-context=*)val="${arg:16}"
OPT_CONTEXT_AFTER="$val"
;;
-C*)val="${arg:2}"
OPT_CONTEXT_BEFORE="$val"
OPT_CONTEXT_AFTER="$val"
;;
-B*)val="${arg:2}"
OPT_CONTEXT_BEFORE="$val"
;;
-A*)val="${arg:2}"
OPT_CONTEXT_AFTER="$val"
esac
done
fi
while shiftopt;do
case "$OPT" in
\
-i|--ignore-case)OPT_CASE_SENSITIVITY="--ignore-case";;
-s|--case-sensitive)OPT_CASE_SENSITIVITY="--case-sensitive";;
-S|--smart-case)OPT_CASE_SENSITIVITY="--smart-case";;
-A*|--after-context)shiftval
OPT_CONTEXT_AFTER="$OPT_VAL"
;;
-B*|--before-context)shiftval
OPT_CONTEXT_BEFORE="$OPT_VAL"
;;
-C*|--context)shiftval
OPT_CONTEXT_BEFORE="$OPT_VAL"
OPT_CONTEXT_AFTER="$OPT_VAL"
;;
-F|--fixed-strings)OPT_FIXED_STRINGS=true
RG_ARGS+=("$OPT")
;;
-U|--multiline|\
-P|--pcre2|\
-z|--search-zip|\
-w|--word-regexp|\
--one-file-system|\
--multiline-dotall|\
--ignore|--no-ignore|\
--crlf|--no-crlf|\
--hidden|--no-hidden)RG_ARGS+=("$OPT")
;;
-E|--encoding|\
-g|--glob|\
-t|--type|\
-T|--type-not|\
-m|--max-count|\
--max-depth|\
--iglob|\
--ignore-file)shiftval
RG_ARGS+=("$OPT" "$OPT_VAL")
;;
\
\
\
--no-follow)OPT_FOLLOW=false;;
--no-snip)OPT_SNIP="";;
--no-highlight)OPT_HIGHLIGHT=false;;
-p|--search-pattern)OPT_SEARCH_PATTERN=true;;
--no-search-pattern)OPT_SEARCH_PATTERN=false;;
\
--rg:*){
if [[ ${OPT:5:1} == "-" ]];then
RG_ARGS+=("${OPT:5}")
else
RG_ARGS+=("--${OPT:5}")
fi
if [[ -n $OPT_VAL ]];then
RG_ARGS+=("$OPT_VAL")
fi
};;
\
-*){
printc "%{RED}%s: unknown option '%s'%{CLEAR}\n" "batgrep" "$OPT" 1>&2
exit 1
};;
\
*){
if [ -z "$PATTERN" ];then
PATTERN="$OPT"
else
FILES+=("$OPT")
fi
}
esac
done
if [[ -z $PATTERN ]];then
print_error "no pattern provided"
exit 1
fi
SEP="$(printc "%{DIM}%${OPT_TERMINAL_WIDTH}s%{CLEAR}"|sed "s/ /─/g")"
if [[ -n $OPT_CASE_SENSITIVITY ]];then
RG_ARGS+=("$OPT_CASE_SENSITIVITY")
fi
if "$OPT_FOLLOW";then
RG_ARGS+=("--follow")
fi
if "$OPT_COLOR";then
BAT_ARGS+=("--color=always")
else
BAT_ARGS+=("--color=never")
fi
if [[ $OPT_CONTEXT_BEFORE -eq 0 && $OPT_CONTEXT_AFTER -eq 0 ]];then
OPT_SNIP=""
OPT_HIGHLIGHT=false
fi
if "$OPT_SEARCH_PATTERN";then
if is_pager_less;then
if "$OPT_FIXED_STRINGS";then
SCRIPT_PAGER_ARGS+=(-p $'\x12'"$PATTERN")
else
SCRIPT_PAGER_ARGS+=(-p "$PATTERN")
fi
elif is_pager_disabled;then
print_error "%s %s %s" \
"The -p/--search-pattern option requires a pager, but" \
'the pager was explicitly disabled by $BAT_PAGER or the' \
"--paging option."
exit 1
else
print_error "Unsupported pager '%s' for option -p/--search-pattern" \
"$(pager_name)"
exit 1
fi
fi
main(){
FOUND_FILES=()
FOUND=0
FIRST_PRINT=true
LAST_LR=()
LAST_LH=()
LAST_FILE=''
do_print(){
[[ -z $LAST_FILE ]]&&return 0
"$FIRST_PRINT"&&echo "$SEP"
FIRST_PRINT=false
"bat" "${BAT_ARGS[@]}" \
"${LAST_LR[@]}" \
"${LAST_LH[@]}" \
--style="$BAT_STYLE$OPT_SNIP" \
--paging=never \
--terminal-width="$OPT_TERMINAL_WIDTH" \
"$LAST_FILE"
echo "$SEP"
}
while IFS=':' read -r file line column text;do
((FOUND++))
if [[ $LAST_FILE != "$file" ]];then
do_print
LAST_FILE="$file"
LAST_LR=()
LAST_LH=()
fi
line_start=$((line-OPT_CONTEXT_BEFORE))
line_end=$((line+OPT_CONTEXT_AFTER))
[[ $line_start -gt 0 ]]||line_start=''
LAST_LR+=("--line-range=$line_start:$line_end")
[[ $OPT_HIGHLIGHT == "true" ]]&&LAST_LH+=("--highlight-line=$line")
done < <(rg --with-filename --vimgrep "${RG_ARGS[@]}" --context=0 --no-context-separator --sort path "$PATTERN" "${FILES[@]}")
do_print
if [[ $FOUND -eq 0 ]];then
exit 2
fi
}
pager_exec main
exit $?
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
function incompatible_function() {
 :
}
compatible_function() {
 if ! [ "$1" == "yes" ]
 then
 return 3;:;
 fi
 
 (
 exec 3>&1
 echo "finished! $@? $*." >&3 \
 | cat | bat - | cat
 exit 4
 ) || exit $?
}
if command -v bat &> /dev/null; then
 var=1
 printf "%s...\n" "$(echo some text)"
 while true; do
 echo $var
 if { [[ "$var" -eq 1 && ( true || false ) ]] || false 2>&1 1> /dev/null; } &> /dev/null; then
 var="$(cat <<< "two")"
 continue 1
 fi
 case "$var" in
 "two") var="three" ;;
 three) var="four" ;;
 fo*r)
 var=five
 ;;
 "fi"ve)
 var="$(
 cat << END
six > $var
END
 )"
 ;;
 $'six\n' | *six*)
 echo "?"
 seven=seven
 while read -r line
 do
 var="$line"
 done << "HEREDOC"
1
2
$seven
HEREDOC
 ;;
 *'sev'*)
 export var=eight
 unset var
 ;;
 '')
 { incompatible_function && false; } || compatible_function "yes"
 break
 ;;
 esac
 continue
 done
fi
@@ -0,0 +1,59 @@
@echo off
:: Change to your LLVM installation
set "LLVMPath=C:\Program Files\LLVM"
:: Change to your Visual Studio 2017 installation
set "VSPath=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
set "VSVersion=14.10.25017"
:: Change to your Windows Kit version & installation
set "WinSDKVersion=10.0.15063.0"
set "WinSDKPath=C:\Program Files (x86)\Windows Kits\10"
:: Change this to your resulting exe
set "OUTPUT=test.exe"
:: Setup
set "VSBasePath=%VSPath%\VC\Tools\MSVC\%VSVersion%"
set "PATH=%PATH%;%LLVMPath%\bin;%VSBasePath%\bin\HostX64\x64"
:: Compiler Flags
set CFLAGS= ^
 -std=c++14 -Wall -Wextra
set CPPFLAGS= ^
 -I "%VSBasePath%\include" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\shared" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\ucrt" ^
 -I "%WinSDKPath%\Include\%WinSDKVersion%\um"
:: Linker Libs
set LDFLAGS= ^
 -machine:x64 ^
 -nodefaultlib ^
 -subsystem:console
set LDLIBS= ^
 -libpath:"%VSBasePath%\lib\x64" ^
 -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\ucrt\x64" ^
 -libpath:"%WinSDKPath%\Lib\%WinSDKVersion%\um\x64" ^
 libucrt.lib libvcruntime.lib libcmt.lib libcpmt.lib ^
 legacy_stdio_definitions.lib oldnames.lib ^
 legacy_stdio_wide_specifiers.lib ^
 kernel32.lib User32.lib
:: Compiling
@echo on
@for %%f in (*.cc) do (
 clang++.exe "%%~f" -o "%%~nf.o" -c %CFLAGS%
)
:: Linking
@set "LINK_FILES="
@for %%f in (*.o) do (
 @set "LINK_FILES=%LINK_FILES% %%~f"
)
lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS%
@@ -0,0 +1,18 @@
@book{knuth1997art,
 title={The art of computer programming},
 author={Knuth, Donald Ervin},
 volume={3},
 year={1997},
 publisher={Pearson Education}
}
@article{egholm1993pna,
 title={PNA hybridizes to complementary oligonucleotides obeying the Watson--Crick hydrogen-bonding rules},
 author={Egholm, Michael and Buchardt, Ole and Christensen, Leif and Behrens, Carsten and Freier, Susan M and Driver, David A and Berg, Rolf H and Kim, Seog K and Norden, Bengt and Nielsen, Peter E},
 journal={Nature},
 volume={365},
 number={6446},
 pages={566--568},
 year={1993},
 publisher={Springer}
}
@@ -0,0 +1,64 @@
namespace StackImplementation
{
 internal class Stack<T>
 {
 private int _top;
 private const int Capacity = 4;
 private readonly T[] _stack = new T[Capacity];
 public Stack()
 {
 _top = -1;
 }
 private bool IsEmpty()
 {
 return _top < 0;
 }
 private bool IsFull()
 {
 return _top == Capacity - 1;
 }
 public void Peek()
 {
 System.Console.WriteLine(!IsEmpty() ? $"The topmost element is: {_stack[_top]}" : "The stack is empty.");
 }
 public T Pop()
 {
 return !IsEmpty() ? _stack[_top--] : default;
 }
 public void Push(T element)
 {
 if (!IsFull())
 {
 _stack[++_top] = element;
 }
 else
 {
 System.Console.WriteLine("Cannot push - the stack is full.");
 }
 }
 public override string ToString()
 {
 if (IsEmpty())
 {
 return "The stack is empty.";
 }
 var depiction = "";
 for (var index = 0; index < _top; index++)
 {
 depiction += _stack[index].ToString() + ' ';
 }
 depiction += _stack[_top].ToString();
 return $"Stack: [{depiction}]";
 }
 }
}
+62
View File
@@ -0,0 +1,62 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
void test_function()
{
#define TEST
#ifdef TEST
 printf("TEST is defined\n");
#endif
}
struct Node
{
 int val;
 struct Node *next;
};
int main(int argc, char **argv)
{
 /* This C program was written to help bat
 * with its syntax highlighting tests
 */
 // Calling test function
 test_function();
 struct Node *head = NULL;
 head = (struct Node *)malloc(sizeof(struct Node *));
 head->val = -1;
 if (head->val == 1 * -1)
 {
 head->val = 10;
 }
 else
 {
 head->val = argc;
 }
 int t = head->val, count = 0;
 free(head);
 while (t--)
 {
 count++;
 }
 for (int i = t; i < count; ++i)
 {
 do
 {
 --count;
 } while (false);
 }
 enum chars
 {
 M,
 I,
 T,
 H,
 L
 };
 char *string = "string";
 printf("true is #define true %d\n", true);
 return 0;
}
@@ -0,0 +1,16 @@
# This is a file for testing syntax highlighting.
cmake_minimum_required(VERSION 3.13)
project(hello-bat VERSION 0.0.1 LANGUAGES C)
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
file(GLOB_RECURSE SOURCES "${SOURCE_DIR}/*.c")
add_executable(hello-bat SOURCES)
find_package(assimp CONFIG)
target_link_libraries(hello-bat assimp)
option("ENABLE_TESTS" OFF)
if(ENABLE_TESTS)
 add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/")
endif()
@@ -0,0 +1,115 @@
/*Scrolling*/
html { scroll-behavior: smooth; }
/*Header text*/
.jumbotron {
 background-image: linear-gradient(90deg, #849EB5, #30394A);
 padding-bottom: 20px;
 padding-top: 20px;
 text-shadow: 0px 2px 4px #000000;
}
.container {
 margin-top: -25px;
}
/*Background related*/
body {
 background: #161616;
}
/*Text related CSS*/
h4 {
 font-size: 70px;
 color: #FFFFFF;
 font-family: News Cycle, serif;
}
h3 {
 color: #e5e5e5;
}
p {
 font-size: 17px;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
p2 {
 font-size: 24px;
 color: #DEDEDE;
 font-family: News Cycle, serif;
}
date {
 font-family: News Cycle, serif;
 font-style: italic;
 font-size: 17px;
 color: #DEDEDE;
}
jobtitle {
 font-size: 17px;
 font-weight: bold;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
jobtilenolink {
 font-size: 17px;
 font-weight: bold;
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
li {
 font-family: News Cycle, serif;
 color: #DEDEDE;
}
a {
 color: #4A8ECC;
}
p a:visited {
 color: #4A8ECC;
}
.href {
 color: #4A8ECC;
}
a:visited {
 color: #4A8ECC;
}
p a:hover {
 color: #4FB1F4;
}
a:hover {
 color: #4FB1F4;
}
jobtitle:hover {
 color: #4FB1F4;
}
/*Section*/
section {
 background-color: #1B1B1B;
 padding: 20px;
 margin: -5px;
 margin-bottom: 30px;
 box-shadow: 0px 2px 4px rgba(0,0,0,0.3);
}
/*Icon related*/
.icon {
 position: relative;
 top: 3px;
 right: 5px;
}
@@ -0,0 +1,7 @@
first,last,address,city,zip
John,Doe,120 any st.,"Anytown, WW",08123
a,b
1,"ha 
""ha"" 
ha",120 any st.,"Anytown, WW",08123
3,4,120 any st.,"Anytown, WW",08123
Can't render this file because it contains an unexpected character in line 2 and column 276.
@@ -0,0 +1,58 @@
(ns clojure-sample.core
 (:gen-class))
 
 (require '[clj-time.core :as t])
 (require '[clj-time.format :as f])
 
 ;; Product record
 (defrecord Product [id name available price])
 
 ;; Positional constructor
 (def product1 (->Product "1" "T-Shirt 1" true 15.00))
 
 ;; Map constructor
 (def product2 (map->Product
 {:id "2"
 :name "T-Shirt 2"
 :available true
 :price 20.00}))
 
 ;; Nested
 (def product3 {:id "1"
 :name "Product 1"
 :available true
 :sellers [{:id "1"
 :name "Seller 1"
 :stock 3},
 {:id 2
 :name "Seller 2"
 :stock 5}]})
 
 ;; Set
 (def categories #{"shirts" "shoes" "belts"})
 
 ;; List
 (def wishlist '(1 2))
 
 ;; Recursion
 (defn factorial [value] (cond
 (<= value 1) 1
 :else (* value (factorial (- value 1)))))
 
 (def basic-formatter (f/formatter "YYYY-MM-dd hh:mm:ss"))
 (defn now [] (f/unparse basic-formatter (t/now)))
 (defn log
 ([] (println (now) "No message"))
 ([message] (println (now) message)))
 
 (defn -main
 [& args]
 (println (:id product1))
 (println (:name product2))
 (println (:name (get (:sellers product3) 0)))
 (println (first categories))
 (println wishlist)
 (println (factorial 5))
 (log)
 (log "Message"))
 
@@ -0,0 +1,79 @@
#include <bits/stdc++.h> // includes most of the useful libraries
#include "mainwindow.h"
using namespace std;
/* This C program was submitted to help bat
 * with its syntax highlighting tests
 */
bool test_function(int x, int y)
{
 return (x == y || x + y == x * y);
}
MainWindow::MainWindow(QWidget *parent)
 : QMainWindow(parent), ui(new Ui::MainWindow)
{
 ui->setupUi(this);
 resize(560, 420);
 // Image menu
 connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::open);
 MainWindow::~MainWindow()
 {
 delete ui;
 }
 int y = ui->graphicsView->size().height() - image.height();
 int x = ui->graphicsView->size().width() - image.width();
 void MainWindow::showImage()
 {
 // Reset scale
 ui->graphicsView->resetMatrix();
 statusBar()->showMessage(QString("%1 %2x%3px %4 kB").arg(file.fileName()).arg(image.width()).arg(image.height()).arg(QFile(currentFile).size() / 1000.0));
 }
}
int main()
{
 int tc;
 cin >> tc;
 while (tc--) // for each test case
 {
 int n;
 cin >> n; // take n
 vector<pair<int, string>> v;
 int a[n], b[n];
 for (int i = 0; i < n; i++)
 cin >> a[i]; // take arrays
 for (int i = 0; i < n; i++)
 cin >> b[i];
 priority_queue<int> pq; // inbuilt data structure - max heap (available in the bits/stdc++)
 for (int i = 0; i < n; i++)
 pq.push(a[i]); // push elements into heap
 for (int i = 0; i < n; i++) // for each element in B
 {
 int top_ele = pq.top(); // max element in heap
 pq.pop(); // deletion
 pq.push(top_ele ^ b[i]); // push after operation
 }
 for (int i = n - 1; i >= 0; i--) // restore A in ascending order
 {
 a[i] = pq.top();
 pq.pop();
 }
 for (int i = 0; i < n; i++)
 cout << a[i] << " "; // print A
 cout << endl;
 }
 return 0;
}
@@ -0,0 +1,45 @@
processor : 0
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
model name : ARMv7 Processor rev 3 (v7l)
BogoMIPS : 270.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Hardware : BCM2711
Revision : b03111
Serial : 1000000095fd9fc5
Model : Raspberry Pi 4 Model B Rev 1.1
@@ -0,0 +1,117 @@
# An example file to test Crystal syntax highlighting in bat
my_var : Nil = nil
my_var_also : Int32 = 42
my_other_var = 4.0
another_float = 4.0_f32
another_float_2 = 4e10
another_float_3 = -0.5
big_one = 1_000_000.111_111e-4
ternary = 1 > 2 : 3 ? 4
my_symbol = :ThisOne?
my_other_symbol = :No_That_One!
plus = :+
minus = :-
my_string : String = "this string right here, with an interpolated value of #{my_var_also}"
my_array : Array(Int32) = [1,2,3,4]
my_tuple : Tuple(Int32, Int32, Int32, Int32) = {1,2,3,4}
my_named_tuple : NamedTuple(one: Int32, two: Int32) = {"one": 1, "two": 2}
my_hash : Hash(String, Int32) = {"one" => 1, "two" => 2}
my_proc : Proc(Int32, Int32) = ->(x : Int32){ x * x}
my_other_proc : Proc(String) = ->{ "Wow, neat!" }
puts my_string
puts(my_string)
enum Colors
 Red
 Green
 Blue
end
class Greeter
 @instance_field = Colors::Red
 @@class_field = Colors::Green
 def initialize(@name = "world")
 end
 def greet 
 puts "Hello, #{@name}"
 end
 def render_greeting : String
 "Hello, #{@name}"
 end
 def with_greeting
 yield render_greeting
 end
 def is_color_default?
 @instance_field == @@class_field
 end
 def self.greet_static(name : String) : Unit
 puts "Hello, #{name}"
 end
end
greeter = Greeter.new("bat")
greeter.with_greeting do |greeting|
 puts greeting
end
puts <<-EOF
 this is a heredoc and it has a value in it of #{greeter.render_greeting}!
EOF
# This is a command:
`echo yay!`
$?.success?
my_color = Colors::Red
puts 
 case my_color
 when Colors::Red, .red?
 "Red"
 when Colors::Green, .green?
 "Green"
 when Colors::Blue, .blue?
 "Blue"
 else
 "I dunno, man. Chartreuse? Maroon?"
 end
class MyGenericClass(T)
 def initialize(@wrapped_value : T)
 end
 def get
 return @wrapped_value
 end
end
def do_stuff_with_range(r : Range(Int|String))
 return if r.empty?
 return unless !(r.empty?)
 r.each do |item|
 if /e/.match(item.to_s)
 puts "#{item} contains the letter e!"
 elsif item.to_s.empty?
 break
 else
 next # this is unnecessary, but whatever
 end
 end
end
macro print_range(range)
 {% for i in range %}
 puts {{i.id}}
 {% end %}
end
print_range(1..3)
print_range(1...3)
+44
View File
@@ -0,0 +1,44 @@
// selective import
import std.stdio : writeln, writefln;
// non-selective import
import std.algorithm;
/* a multiline comment
*
* this function is safe because it doesn't use pointer arithmetic
*/
int the_ultimate_answer() @safe {
 // assert1on
 assert(1 != 2);
 // now we can safely return our answer 
 return 42;
}
void main()
{
 // function call with string literal
 writeln("Hello World!");
 // an int array declaration
 int[] arr1 = [1, 2, 3];
 // an immutable double
 immutable double pi = 3.14;
 // a mutable double
 double d1 = pi;
 // a pointer
 double* dp1 = &d1;
 // another pointer to the same thingy
 auto a1 = &d1;
 // a constant bool
 const bool b1 = true;
 if (b1) {
 // another function call 
 writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
 }
 else if (!b1) {
 writeln("this seems wrong");
 }
 else {
 writeln("I'm giving up, this is too crazy for me");
 }
}
@@ -0,0 +1,133 @@
/* array sorting alogorithm */
int partition(List list, int low, int high) {
 if (list == null || list.length == 0) return 0;
 int pivot = list[high];
 int i = low - 1;
 void swap(List list, int i, int j) {
 int temp = list[i];
 list[i] = list[j];
 list[j] = temp;
 }
 for (int j = low; j < high; j++) {
 if (list[j] <= pivot) {
 i++;
 swap(list, i, j);
 }
 swap(list, i + 1, high);
 return i + 1;
 }
}
void quickSort(List list, int low, int high) {
 if (low < high) {
 int pi = partition(list, low, high);
 quickSort(list, low, pi - 1);
 quickSort(list, pi + 1, high);
 }
}
void merge(List list, int leftIndex, int middleIndex, int rightIndex) {
 int leftSize = middleIndex - leftIndex + 1;
 int rightSize = rightIndex - middleIndex;
 List leftList = new List(leftSize);
 List rightList = new List(rightSize);
 for (int i = 0; i < leftSize; i++) leftList[i] = list[leftIndex + i];
 for (int j = 0; j < rightSize; j++) rightList[j] = list[middleIndex + j + 1];
 int i = 0, j = 0;
 int k = leftIndex;
 while (i < leftSize && j < rightSize) {
 if (leftList[i] <= rightList[j]) {
 list[k] = leftList[i];
 i++;
 } else {
 list[k] = rightList[j];
 j++;
 }
 k++;
 }
 while (i < leftSize) {
 list[k] = leftList[i];
 i++;
 k++;
 }
 while (j < rightSize) {
 list[k] = rightList[j];
 j++;
 k++;
 }
}
void mergeSort(List list, int leftIndex, int rightIndex) {
 if (leftIndex < rightIndex) {
 int middleIndex = (rightIndex + leftIndex) ~/ 2;
 mergeSort(list, leftIndex, middleIndex);
 mergeSort(list, middleIndex + 1, rightIndex);
 merge(list, leftIndex, middleIndex, rightIndex);
 }
}
/* variables */
var name = 'Voyager I';
var year = 1977;
var antennaDiameter = 3.7;
var flybyObjects = ['Jupiter', 'Saturn', 'Uranus', 'Neptune'];
var image = {
 'tags': ['saturn'],
 'url': '//path/to/saturn.jpg'
};
/*classes */
class Spacecraft {
 String name;
 DateTime launchDate;
 Spacecraft(this.name, this.launchDate) {}
 // Named constructor that forwards to the default one.
 Spacecraft.unlaunched(String name) : this(name, null);
 int get launchYear => launchDate?.year;
 void describe() {
 print('Spacecraft: $name');
 if (launchDate != null) {
 int years = DateTime.now().difference(launchDate).inDays ~/ 365;
 print('Launched: $launchYear ($years years ago)');
 } else {
 print('Unlaunched');
 }
 }
}
/* Mixins */
class PilotedCraft extends Spacecraft with Piloted {
 // ···
}
/* Interfaces and abstract classes */
class MockSpaceship implements Spacecraft {
 // ···
}
/* async */
Future<void> printWithDelay(String message) {
 return Future.delayed(const Duration(seconds: 2)).then((_) {
 print(message);
 });
}
Stream<String> report(Spacecraft craft, Iterable<String> objects) async* {
 for (var object in objects) {
 await Future.delayed(const Duration(seconds: 2));
 yield '${craft.name} flies by $object';
 }
}
@@ -0,0 +1,353 @@
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ced88213..973eba9a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
 
 
 ## Features
+
+- Add a new `--diff` 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
 ## Other
 ## `bat` as a library
diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs
index e5221455..f0f519ea 100644
--- a/src/bin/bat/app.rs
+++ b/src/bin/bat/app.rs
@@ -15,7 +15,7 @@ use console::Term;
 
 use bat::{
 assets::HighlightingAssets,
- config::Config,
+ config::{Config, VisibleLines},
 error::*,
 input::Input,
 line_range::{HighlightedLineRanges, LineRange, LineRanges},
@@ -196,13 +196,23 @@ impl App {
 }
 })
 .unwrap_or_else(|| String::from(HighlightingAssets::default_theme())),
- line_ranges: self
- .matches
- .values_of("line-range")
- .map(|vs| vs.map(LineRange::from).collect())
- .transpose()?
- .map(LineRanges::from)
- .unwrap_or_default(),
+ visible_lines: if self.matches.is_present("diff") {
+ VisibleLines::DiffContext(
+ self.matches
+ .value_of("diff-context")
+ .and_then(|t| t.parse().ok())
+ .unwrap_or(2),
+ )
+ } else {
+ VisibleLines::Ranges(
+ self.matches
+ .values_of("line-range")
+ .map(|vs| vs.map(LineRange::from).collect())
+ .transpose()?
+ .map(LineRanges::from)
+ .unwrap_or_default(),
+ )
+ },
 style_components,
 syntax_mapping,
 pager: self.matches.value_of("pager"),
diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs
index c7344991..85edefde 100644
--- a/src/bin/bat/clap_app.rs
+++ b/src/bin/bat/clap_app.rs
@@ -105,6 +105,34 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
 data to bat from STDIN when bat does not otherwise know \
 the filename."),
 )
+ .arg(
+ Arg::with_name("diff")
+ .long("diff")
+ .help("Only show lines that have been added/removed/modified.")
+ .long_help(
+ "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.",
+ ),
+ )
+ .arg(
+ Arg::with_name("diff-context")
+ .long("diff-context")
+ .overrides_with("diff-context")
+ .takes_value(true)
+ .value_name("N")
+ .validator(
+ |n| {
+ n.parse::<usize>()
+ .map_err(|_| "must be a number")
+ .map(|_| ()) // Convert to Result<(), &str>
+ .map_err(|e| e.to_string())
+ }, // Convert to Result<(), String>
+ )
+ .hidden_short_help(true)
+ .long_help(
+ "Include N lines of context around added/removed/modified lines when using '--diff'.",
+ ),
+ )
 .arg(
 Arg::with_name("tabs")
 .long("tabs")
@@ -339,6 +367,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
 .takes_value(true)
 .number_of_values(1)
 .value_name("N:M")
+ .conflicts_with("diff")
 .help("Only print the lines from N to M.")
 .long_help(
 "Only print the specified range of lines for each file. \
diff --git a/src/config.rs b/src/config.rs
index d5df9910..3c24b77f 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -5,6 +5,32 @@ use crate::style::StyleComponents;
 use crate::syntax_mapping::SyntaxMapping;
 use crate::wrapping::WrappingMode;
 
+#[derive(Debug, Clone)]
+pub enum VisibleLines {
+ /// Show all lines which are included in the line ranges
+ Ranges(LineRanges),
+
+ #[cfg(feature = "git")]
+ /// Only show lines surrounding added/deleted/modified lines
+ DiffContext(usize),
+}
+
+impl VisibleLines {
+ pub fn diff_context(&self) -> bool {
+ match self {
+ Self::Ranges(_) => false,
+ #[cfg(feature = "git")]
+ Self::DiffContext(_) => true,
+ }
+ }
+}
+
+impl Default for VisibleLines {
+ fn default() -> Self {
+ VisibleLines::Ranges(LineRanges::default())
+ }
+}
+
 #[derive(Debug, Clone, Default)]
 pub struct Config<'a> {
 /// The explicitly configured language, if any
@@ -39,8 +65,8 @@ pub struct Config<'a> {
 #[cfg(feature = "paging")]
 pub paging_mode: PagingMode,
 
- /// Specifies the lines that should be printed
- pub line_ranges: LineRanges,
+ /// Specifies which lines should be printed
+ pub visible_lines: VisibleLines,
 
 /// The syntax highlighting theme
 pub theme: String,
@@ -62,10 +88,7 @@ pub struct Config<'a> {
 fn default_config_should_include_all_lines() {
 use crate::line_range::RangeCheckResult;
 
- assert_eq!(
- Config::default().line_ranges.check(17),
- RangeCheckResult::InRange
- );
+ assert_eq!(LineRanges::default().check(17), RangeCheckResult::InRange);
 }
 
 #[test]
diff --git a/src/controller.rs b/src/controller.rs
index 09c6ec2a..f636d5fd 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -1,9 +1,13 @@
 use std::io::{self, Write};
 
 use crate::assets::HighlightingAssets;
-use crate::config::Config;
+use crate::config::{Config, VisibleLines};
+#[cfg(feature = "git")]
+use crate::diff::{get_git_diff, LineChanges};
 use crate::error::*;
 use crate::input::{Input, InputReader, OpenedInput};
+#[cfg(feature = "git")]
+use crate::line_range::LineRange;
 use crate::line_range::{LineRanges, RangeCheckResult};
 use crate::output::OutputType;
 #[cfg(feature = "paging")]
@@ -68,6 +72,32 @@ impl<'b> Controller<'b> {
 no_errors = false;
 }
 Ok(mut opened_input) => {
+ #[cfg(feature = "git")]
+ let line_changes = if self.config.visible_lines.diff_context()
+ || (!self.config.loop_through && self.config.style_components.changes())
+ {
+ if let crate::input::OpenedInputKind::OrdinaryFile(ref path) =
+ opened_input.kind
+ {
+ let diff = get_git_diff(path);
+
+ if self.config.visible_lines.diff_context()
+ && diff
+ .as_ref()
+ .map(|changes| changes.is_empty())
+ .unwrap_or(false)
+ {
+ continue;
+ }
+
+ diff
+ } else {
+ None
+ }
+ } else {
+ None
+ };
+
 let mut printer: Box<dyn Printer> = if self.config.loop_through {
 Box::new(SimplePrinter::new())
 } else {
@@ -75,10 +105,18 @@ impl<'b> Controller<'b> {
 &self.config,
 &self.assets,
 &mut opened_input,
+ #[cfg(feature = "git")]
+ &line_changes,
 ))
 };
 
- let result = self.print_file(&mut *printer, writer, &mut opened_input);
+ let result = self.print_file(
+ &mut *printer,
+ writer,
+ &mut opened_input,
+ #[cfg(feature = "git")]
+ &line_changes,
+ );
 
 if let Err(error) = result {
 handle_error(&error);
@@ -96,13 +134,31 @@ impl<'b> Controller<'b> {
 printer: &mut dyn Printer,
 writer: &mut dyn Write,
 input: &mut OpenedInput,
+ #[cfg(feature = "git")] line_changes: &Option<LineChanges>,
 ) -> Result<()> {
 if !input.reader.first_line.is_empty() || self.config.style_components.header() {
 printer.print_header(writer, input)?;
 }
 
 if !input.reader.first_line.is_empty() {
- self.print_file_ranges(printer, writer, &mut input.reader, &self.config.line_ranges)?;
+ let line_ranges = match self.config.visible_lines {
+ VisibleLines::Ranges(ref line_ranges) => line_ranges.clone(),
+ #[cfg(feature = "git")]
+ VisibleLines::DiffContext(context) => {
+ let mut line_ranges: Vec<LineRange> = vec![];
+
+ if let Some(line_changes) = line_changes {
+ for line in line_changes.keys() {
+ let line = *line as usize;
+ line_ranges.push(LineRange::new(line - context, line + context));
+ }
+ }
+
+ LineRanges::from(line_ranges)
+ }
+ };
+
+ self.print_file_ranges(printer, writer, &mut input.reader, &line_ranges)?;
 }
 printer.print_footer(writer, input)?;
 
diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs
index 0c78ea90..13bd5dbc 100644
--- a/src/pretty_printer.rs
+++ b/src/pretty_printer.rs
@@ -6,7 +6,7 @@ use syntect::parsing::SyntaxReference;
 
 use crate::{
 assets::HighlightingAssets,
- config::Config,
+ config::{Config, VisibleLines},
 controller::Controller,
 error::Result,
 input::Input,
@@ -205,7 +205,7 @@ impl<'a> PrettyPrinter<'a> {
 
 /// Specify the lines that should be printed (default: all)
 pub fn line_ranges(&mut self, ranges: LineRanges) -> &mut Self {
- self.config.line_ranges = ranges;
+ self.config.visible_lines = VisibleLines::Ranges(ranges);
 self
 }
 
diff --git a/src/printer.rs b/src/printer.rs
index 5eed437e..2b245cfd 100644
--- a/src/printer.rs
+++ b/src/printer.rs
@@ -24,7 +24,7 @@ use crate::config::Config;
 use crate::decorations::LineChangesDecoration;
 use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration};
 #[cfg(feature = "git")]
-use crate::diff::{get_git_diff, LineChanges};
+use crate::diff::LineChanges;
 use crate::error::*;
 use crate::input::OpenedInput;
 use crate::line_range::RangeCheckResult;
@@ -90,7 +90,7 @@ pub(crate) struct InteractivePrinter<'a> {
 ansi_prefix_sgr: String,
 content_type: Option<ContentType>,
 #[cfg(feature = "git")]
- pub line_changes: Option<LineChanges>,
+ pub line_changes: &'a Option<LineChanges>,
 highlighter: Option<HighlightLines<'a>>,
 syntax_set: &'a SyntaxSet,
 background_color_highlight: Option<Color>,
@@ -101,6 +101,7 @@ impl<'a> InteractivePrinter<'a> {
 config: &'a Config,
 assets: &'a HighlightingAssets,
 input: &mut OpenedInput,
+ #[cfg(feature = "git")] line_changes: &'a Option<LineChanges>,
 ) -> Self {
 let theme = assets.get_theme(&config.theme);
 
@@ -145,9 +146,6 @@ impl<'a> InteractivePrinter<'a> {
 panel_width = 0;
 }
 
- #[cfg(feature = "git")]
- let mut line_changes = None;
-
 let highlighter = if input
 .reader
 .content_type
@@ -155,18 +153,6 @@ impl<'a> InteractivePrinter<'a> {
 {
 None
 } else {
- // Get the Git modifications
- #[cfg(feature = "git")]
- {
- use crate::input::OpenedInputKind;
-
- if config.style_components.changes() {
- if let OpenedInputKind::OrdinaryFile(ref path) = input.kind {
- line_changes = get_git_diff(path);
- }
- }
- }
-
 // Determine the type of syntax for highlighting
 let syntax = assets.get_syntax(config.language, input, &config.syntax_mapping);
 Some(HighlightLines::new(syntax, theme))
@@ -0,0 +1,19 @@
ARG architecture=amd64
FROM $architecture/centos:7
LABEL com.example.version="0.2.1-beta"
ARG architecture
ENV INTERESTING_PATH /usr/bin/interesting-software
COPY entrypoint.sh /usr/bin/entrypoint.sh
RUN if [ "$architecture" = "i386" ]; then echo "Building i386 docker image" && \
 linux32 yum update -y && linux32 yum install -y mysql ; \
 else yum update -y && yum install -y mysql
EXPOSE 80/tcp
VOLUME [/var/lib/mysql/data]
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
@@ -0,0 +1,57 @@
# Keyword
export TEST_KEYWORD="bar"
export TEST_KEYWORD=12345
export TEST_KEYWORD=TRUE
# Variable
TEST_VARIABLE="Hello"
# String interpolation
TEST_INTERPOLATION_VARIABLE="$VAR1 test test$VAR2test test"
TEST_INTERPOLATION_SYNTAX_ONE="test test{$NVAR1}test{$NVAR2}test test"
TEST_INTERPOLATION_SYNTAX_TWO="test test${NVAR1}test${NVAR2}test test"
TEST_INTERPOLATION_SYNTAX_ALL="test$VAR1test test {VAR2}test test${VAR3}test"
# Unquoted
TEST_UNQUOTED=bar
TEST_UNQUOTED_NO_VALUE=
# White spaced
TEST_WHITE_SPACE =
TEST_WHITE_SPACE_STRING = "Hello"
TEST_WHITE_SPACE_UNQUOTED = bar
TEST_WHITE_SPACE_UNQUOTED_BOOL = false
TEST_WHITE_SPACE_UNQUOTED_NUM = 20
# language constants
TEST_TRUE=true
TEST_FALSE=false
TEST_NULL=null
TEST_TRUE_CAPITAL=TRUE
TEST_FALSE_CAPITAL=FALSE
TEST_NULL_CAPITAL=NULL
# Numerical values
TEST_NUM_DECIMAL=54
TEST_NUM_FLOAT=5.3
TEST_NUM=1e10
TEST_NUM_NEGATIVE=-42
TEST_NUM_OCTAL=057
TEST_NUM_HEX=0x1A
# Comments
#TEST_ONE=foobar
# TEST_TWO='foobar'
# TEST_THREE="foobar" # a comment on a commented row
TEST_FOUR="test test test" # this is a comment
TEST_FIVE="comment symbol # inside string" # this is a comment
TEST_SIX="comment symbol # and quotes \" \' inside quotes" # " this is a comment
# Escape sequences
TEST_ESCAPE="escaped characters \n \t \r \" \' \$ or maybe a backslash \\..."
# Double Quotes
TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\"
# Single Quotes
TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\'
@@ -0,0 +1,31 @@
defmodule Charlex.Command do
 @callback usage() :: [String.t()]
 @callback description() :: String.t()
 @callback parse_args(args :: String.t()) :: any()
 @callback run(context :: Map.t(), args :: [String.t()] | any()) :: String.t() | any()
 @optional_callbacks usage: 0, description: 0, parse_args: 1
 defmacro __using__(_opts) do
 quote do
 @behaviour unquote(__MODULE__)
 @impl true
 def usage, do: "This command is without usage, will add it soon"
 @impl true
 def description, do: "This command is without description, will add it soon"
 @impl true
 def run(_context, _args), do: :ok
 @impl true
 def parse_args(args), do: args |> String.split() |> Kernel.tl()
 defoverridable parse_args: 1, description: 0, run: 2, usage: 0
 end
 end
end
+137
View File
@@ -0,0 +1,137 @@
-- elm install elm-explorations/linear-algebra
-- elm install elm-explorations/webgl
import Browser
import Browser.Events as E
import Html exposing (Html)
import Html.Attributes exposing (width, height, style)
import Math.Matrix4 as Mat4 exposing (Mat4)
import Math.Vector3 as Vec3 exposing (Vec3, vec3)
import WebGL
-- MAIN
main =
 Browser.element
 { init = init
 , view = view
 , update = update
 , subscriptions = subscriptions
 }
-- MODEL
type alias Model =
 Float
init : () -> (Model, Cmd Msg)
init () =
 ( 0, Cmd.none )
-- UPDATE
type Msg
 = TimeDelta Float
update : Msg -> Model -> (Model, Cmd Msg)
update msg currentTime =
 case msg of
 TimeDelta delta ->
 ( delta + currentTime, Cmd.none )
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions _ =
 E.onAnimationFrameDelta TimeDelta
-- VIEW
view : Model -> Html msg
view t =
 WebGL.toHtml
 [ width 400, height 400, style "display" "block"
 ]
 [ WebGL.entity vertexShader fragmentShader mesh { perspective = perspective (t / 1000) }
 ]
perspective : Float -> Mat4
perspective t =
 Mat4.mul
 (Mat4.makePerspective 45 1 0.01 100)
 (Mat4.makeLookAt (vec3 (4 * cos t) 0 (4 * sin t)) (vec3 0 0 0) (vec3 0 1 0))
-- MESH
type alias Vertex =
 { position : Vec3
 , color : Vec3
 }
mesh : WebGL.Mesh Vertex
mesh =
 WebGL.triangles
 [ ( Vertex (vec3 0 0 0) (vec3 1 0 0)
 , Vertex (vec3 1 1 0) (vec3 0 1 0)
 , Vertex (vec3 1 -1 0) (vec3 0 0 1)
 )
 ]
-- SHADERS
type alias Uniforms =
 { perspective : Mat4
 }
vertexShader : WebGL.Shader Vertex Uniforms { vcolor : Vec3 }
vertexShader =
 [glsl|
 attribute vec3 position;
 attribute vec3 color;
 uniform mat4 perspective;
 varying vec3 vcolor;
 void main () {
 gl_Position = perspective * vec4(position, 1.0);
 vcolor = color;
 }
 |]
fragmentShader : WebGL.Shader {} Uniforms { vcolor : Vec3 }
fragmentShader =
 [glsl|
 precision mediump float;
 varying vec3 vcolor;
 void main () {
 gl_FragColor = vec4(vcolor, 1.0);
 }
 |]
@@ -0,0 +1,72 @@
-module(bat_erlang).
-export([main/0]).
-record(test, {
 name :: list(),
 data :: binary()
}).
-define(TESTMACRO, "testmacro").
-spec main() -> ok.
main() ->
 %% Handling Lists and Numbers
 List = [1, 2, 3, 4, $6, 2#00111],
 _Sum = lists:sum(List),
 _ = [(N * N) + N / N - N || N <- List, N > 2],
 [_Head, _SecondHead | _Tail] = List,
 _ = [1, atom, [list], <<"binary">>, {tuple, tuple}, #{map => key}, #test{name = "record"}],
 %% Handling Binaries 
 BinHelloWorld = <<"Hello World">>,
 <<X || <<X:1/binary>> <= BinHelloWorld >>,
 <<0,0,0,0,0,0,0,151>> = <<151:64/signed-integer>>,
 %% Handling Boolean and Atoms
 true = true andalso true,
 true = false orelse true,
 _ = true =:= true,
 _ = false =/= true,
 _ = 'HELLO' /= hello,
 _ = hello == world,
 %% Handling Maps and Records
 TestMap = #{a => 1, b => 2, c => 3},
 #{a := _Value, c := _} = TestMap,
 _ = TestMap#{d => 4},
 Record = #test{name = ?TESTMACRO},
 _ = Record#test.name,
 %% Conditionals
 case TestMap of
 #{b := B} ->
 B;
 _ ->
 ok
 end,
 if
 erlang:is_map(TestMap) ->
 map;
 true ->
 test_function(1)
 end,
 %% Messaging
 Self = erlang:self(),
 Self ! hello_world,
 receive
 hello_world ->
 ok;
 _ ->
 io:format("unknown message")
 after 1000 ->
 timeout
 end,
 ok.
test_function(N) when erlang:is_integer(N) -> integer;
test_function([_|_]) -> list;
test_function(<<_/binary>>) -> binary;
test_function(_) ->
 undefined.
@@ -0,0 +1,67 @@
root:x:0:root
sys:x:3:bin
mem:x:8:
ftp:x:11:
mail:x:12:
log:x:19:
smmsp:x:25:
proc:x:26:polkitd
games:x:50:
lock:x:54:
network:x:90:
floppy:x:94:
scanner:x:96:
power:x:98:
adm:x:999:daemon
wheel:x:998:username
kmem:x:997:
tty:x:5:
utmp:x:996:
audio:x:995:mpd,username
disk:x:994:
input:x:993:
kvm:x:992:
lp:x:991:
optical:x:990:username
render:x:989:
storage:x:988:username
uucp:x:987:
video:x:986:username
users:x:985:
systemd-journal:x:984:
rfkill:x:983:
bin:x:1:daemon
daemon:x:2:bin
http:x:33:
nobody:x:65534:
dbus:x:81:
systemd-journal-remote:x:982:
systemd-network:x:981:
systemd-resolve:x:980:
systemd-timesync:x:979:
systemd-coredump:x:978:
uuidd:x:68:
username:x:1000:
git:x:977:
avahi:x:976:
colord:x:975:
polkitd:x:102:
mpd:x:45:
rtkit:x:133:
transmission:x:169:
wireshark:x:150:username
lightdm:x:974:
geoclue:x:973:
usbmux:x:140:
dhcpcd:x:972:
brlapi:x:971:
gdm:x:120:
libvirt:x:970:
flatpak:x:969:
gluster:x:968:
rpc:x:32:
tor:x:43:
rslsync:x:967:
docker:x:966:username
sambashare:x:1002:username
named:x:40:
@@ -0,0 +1,77 @@
set fish_greeting ""
begin
 set --local AUTOJUMP_PATH $XDG_CONFIG_HOME/fish/functions/autojump.fish
 if test -e $AUTOJUMP_PATH
 source $AUTOJUMP_PATH
 end
end
fish_vi_key_bindings
function fish_prompt
 set_color brblack
 echo -n "["(date "+%H:%M")"] "
 set_color blue
 echo -n (hostname)
 if [ $PWD != $HOME ]
 set_color brblack
 echo -n ':'
 set_color yellow
 echo -n (basename $PWD)
 end
 set_color green
 printf '%s ' (__fish_git_prompt)
 set_color red
 echo -n '| '
 set_color normal
end
function fish_greeting
 echo
 echo -e (uname -ro | awk '{print " \\\\e[1mOS: \\\\e[0;32m"$0"\\\\e[0m"}')
 echo -e (uptime -p | sed 's/^up //' | awk '{print " \\\\e[1mUptime: \\\\e[0;32m"$0"\\\\e[0m"}')
 echo -e (uname -n | awk '{print " \\\\e[1mHostname: \\\\e[0;32m"$0"\\\\e[0m"}')
 echo -e " \\e[1mDisk usage:\\e[0m"
 echo
 echo -ne (\
 df -l -h | grep -E 'dev/(xvda|sd|mapper)' | \
 awk '{printf "\\\\t%s\\\\t%4s / %4s %s\\\\n\n", $6, $3, $2, $5}' | \
 sed -e 's/^\(.*\([8][5-9]\|[9][0-9]\)%.*\)$/\\\\e[0;31m\1\\\\e[0m/' -e 's/^\(.*\([7][5-9]\|[8][0-4]\)%.*\)$/\\\\e[0;33m\1\\\\e[0m/' | \
 paste -sd ''\
 )
 echo
 echo -e " \\e[1mNetwork:\\e[0m"
 echo
 # http://tdt.rocks/linux_network_interface_naming.html
 echo -ne (\
 ip addr show up scope global | \
 grep -E ': <|inet' | \
 sed \
 -e 's/^[[:digit:]]\+: //' \
 -e 's/: <.*//' \
 -e 's/.*inet[[:digit:]]* //' \
 -e 's/\/.*//'| \
 awk 'BEGIN {i=""} /\.|:/ {print i" "$0"\\\n"; next} // {i = $0}' | \
 sort | \
 column -t -R1 | \
 # public addresses are underlined for visibility \
 sed 's/ \([^ ]\+\)$/ \\\e[4m\1/' | \
 # private addresses are not \
 sed 's/m\(\(10\.\|172\.\(1[6-9]\|2[0-9]\|3[01]\)\|192\.168\.\).*\)/m\\\e[24m\1/' | \
 # unknown interfaces are cyan \
 sed 's/^\( *[^ ]\+\)/\\\e[36m\1/' | \
 # ethernet interfaces are normal \
 sed 's/\(\(en\|em\|eth\)[^ ]* .*\)/\\\e[39m\1/' | \
 # wireless interfaces are purple \
 sed 's/\(wl[^ ]* .*\)/\\\e[35m\1/' | \
 # wwan interfaces are yellow \
 sed 's/\(ww[^ ]* .*\).*/\\\e[33m\1/' | \
 sed 's/$/\\\e[0m/' | \
 sed 's/^/\t/' \
 )
 echo
 set_color normal
end
@@ -0,0 +1,42 @@
#version 330 core
#ifdef TEST
layout (location = 0) in vec4 vertex;
#else
layout (location = 6) in vec4 vertex;
#endif
out vec2 p_textureVertex;
/*
 * This stores offsets
 */
struct Data
{
 double offsetX;
 double offsetY;
}
uniform mat4 projectionMatrix;
uniform bool test;
uniform Data data;
double calc()
{
 if (test)
 {
 return 1.0;
 }
 else
 {
 return 0.0;
 }
}
void main()
{
 // This GLSL code serves the purpose of bat syntax highlighting tests
 double x = data.offsetX + calc();
 gl_Position = projectionMatrix * vec4(vertex.xy, data.offsetX, data.offsetY);
 p_textureVertex = vertex.zw;
}
@@ -0,0 +1,16 @@
#
# Comment
[attr]binary -diff -merge -text
* text=auto
*.c diff=c
*.cc text diff=cpp
*.o binary
*.bat text eol=crlf
*.lock text -diff
*.*ignore text
*.patch -text
.gitattributes linguist-language=gitattributes
.gitkeep export-ignore

Some files were not shown because too many files have changed in this diff Show More