mirror of
https://github.com/sharkdp/bat
synced 2026-08-03 18:51:44 +00:00
Compare commits
600 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 589df6792f | |||
| 945bba777b | |||
| 64763eafbe | |||
| 3da4651569 | |||
| 311ed2feca | |||
| 33c11d64f0 | |||
| a4b674902f | |||
| 3fa09dbe2e | |||
| bf2b2df9c9 | |||
| 3617c98cf5 | |||
| 774d36c989 | |||
| 6abd61865f | |||
| 3c59b98dc8 | |||
| 21338ed789 | |||
| dc8ab0b5ce | |||
| ddb39ef2f6 | |||
| 355e62efe9 | |||
| fddd11a205 | |||
| 8b37e62cf3 | |||
| 4296d47dcb | |||
| 42f1ef019a | |||
| fe8e526292 | |||
| 0e9d612173 | |||
| 06c601bc7c | |||
| 229fbc1a18 | |||
| e05f5010da | |||
| 073b9968c0 | |||
| d3aa17ae77 | |||
| 4187eed12b | |||
| 12ecb325c9 | |||
| 90e48e9b61 | |||
| 35f31270f3 | |||
| 2a71852070 | |||
| c8dd32802d | |||
| 71f04dc0e8 | |||
| 49f8bbfee4 | |||
| f4217eba73 | |||
| 14900f6ed8 | |||
| c18afcb01a | |||
| 63043d4a60 | |||
| 76034880ae | |||
| 768189859a | |||
| 6e5a2a5c51 | |||
| 9935c4984c | |||
| a0a5e30c39 | |||
| 4126bbeead | |||
| a5b79295d7 | |||
| e917784932 | |||
| f46b90d28d | |||
| 64cbfbed47 | |||
| 1ced35ec76 | |||
| 16d346773b | |||
| b02120cf66 | |||
| 702b5caf2d | |||
| d395f64f58 | |||
| c9627040cc | |||
| b1f69434f9 | |||
| bcca56e3b1 | |||
| 2f98610929 | |||
| 89539ff247 | |||
| aa74d19940 | |||
| cf7d9ef962 | |||
| 425a0f90e9 | |||
| a27814db8e | |||
| 9702f5256c | |||
| 23fd11e806 | |||
| 304ee1489c | |||
| 07d4179274 | |||
| 1439dde265 | |||
| bef0bf1654 | |||
| 8435cad602 | |||
| 52c11fe23d | |||
| 6fc9641f6a | |||
| 8b6341458b | |||
| 8b787b4f70 | |||
| ef5154d5b3 | |||
| 7c49919297 | |||
| 395a169104 | |||
| 93f710bdff | |||
| 170badfdd1 | |||
| 978b9adc56 | |||
| 3aea51455b | |||
| f827ed338b | |||
| 73dab51ad1 | |||
| 9328007d05 | |||
| 8d173cd960 | |||
| fb0f12a221 | |||
| 9866408b72 | |||
| aaac56d895 | |||
| 516da7719f | |||
| d4df0b4405 | |||
| bfa9c3bef6 | |||
| 2904f24ea8 | |||
| 91a347bf6d | |||
| e219c8fc03 | |||
| 9eb26b702c | |||
| c933be926d | |||
| fc88040b31 | |||
| 5db3c93057 | |||
| aa442b5795 | |||
| 09711cd6f9 | |||
| b16cacc758 | |||
| 51451a9636 | |||
| fbc03da997 | |||
| 1a610dbdd2 | |||
| a30e3c9066 | |||
| 613b41e357 | |||
| d405aa98d5 | |||
| 285b1556a9 | |||
| 8321cc661c | |||
| 848ceb6f10 | |||
| 3559079de0 | |||
| b3ab843954 | |||
| 867cf63dd9 | |||
| 0b44aa6f68 | |||
| aa09a9dc04 | |||
| 7c4edacb2b | |||
| 782ede5db5 | |||
| 1537733e6b | |||
| ba0d43672b | |||
| 4384d25c79 | |||
| b6e3786529 | |||
| 6fff01397d | |||
| 0cd52e5be1 | |||
| c14dd34dca | |||
| e04fbd1992 | |||
| d89fa3ebc2 | |||
| db57454f3f | |||
| 8f93844427 | |||
| 52f84b063c | |||
| 2e7f2b6c07 | |||
| 35347c2310 | |||
| b489fc75c9 | |||
| fc24cb2a77 | |||
| 2540311cdf | |||
| 3880888286 | |||
| 5a806c2149 | |||
| 8a926d511a | |||
| 8885285b10 | |||
| d1f0181947 | |||
| b147443c32 | |||
| b8a18d3ebb | |||
| 694b31909a | |||
| a98811b6d7 | |||
| cfc505e1e5 | |||
| 3af3549232 | |||
| 643f0bcbe3 | |||
| 9db9a38565 | |||
| ca60937c2e | |||
| 2aa3ed9da8 | |||
| 7768433d09 | |||
| c569774e1a | |||
| 0371f55541 | |||
| bc35592fd9 | |||
| f5d834407e | |||
| 557a748ac7 | |||
| 3f10f71ad2 | |||
| 7b6388b19f | |||
| b98ec4bbc5 | |||
| 94fd481f36 | |||
| 94496df3b0 | |||
| 0e5ea9c354 | |||
| 7eabb5e05a | |||
| 9ad401be87 | |||
| f874c8e4db | |||
| 025c5c061b | |||
| 573f34d757 | |||
| eac36dd3b5 | |||
| 70cf8a4ec5 | |||
| 37d0d8984c | |||
| 2e8c0a39db | |||
| deec2902e4 | |||
| e3343759b7 | |||
| fa72f86e17 | |||
| 6527126e50 | |||
| 4aec022065 | |||
| a26c5b8219 | |||
| d36b091fd7 | |||
| 3dcf02549e | |||
| e402011a73 | |||
| dc1620d1f0 | |||
| c48e779e8a | |||
| dd0d44bbb3 | |||
| 060b9981b5 | |||
| b25713938d | |||
| 5b09561114 | |||
| fcde4824d5 | |||
| b0e5828d3f | |||
| b7d499d1be | |||
| 1ae16fca90 | |||
| 0e2bef3b79 | |||
| 221c9815a5 | |||
| c5c683f67c | |||
| 149a0177cd | |||
| 252e5a6b13 | |||
| faa27ed6e3 | |||
| f3227c259e | |||
| 2cfeebab90 | |||
| 8dd67cca0c | |||
| eda72c31b2 | |||
| 7809008016 | |||
| c2c2b0211a | |||
| dd6f57e107 | |||
| dfe7a60140 | |||
| fc30277cfa | |||
| 02e6ff4183 | |||
| e3b1142364 | |||
| 8832ff3c6a | |||
| 505ff10dc6 | |||
| 9a3a5545e7 | |||
| 43919066ad | |||
| 7ada963ec2 | |||
| 4c523af1ab | |||
| c5c28eb05b | |||
| 22924532d0 | |||
| 7c227169a4 | |||
| 8e4b0b4377 | |||
| 6d27df3b77 | |||
| 73d14f4655 | |||
| 19b8c53c46 | |||
| cd7be018fe | |||
| 03a2710a08 | |||
| 09fbabb0b8 | |||
| de6cb75f4b | |||
| 83c9cb7907 | |||
| 7ffb04a17a | |||
| c38c186d26 | |||
| e22a9a69b1 | |||
| 59f9adc706 | |||
| fed30b1b36 | |||
| 411d68e839 | |||
| 77d42a17c6 | |||
| e7c55bffe9 | |||
| da10166625 | |||
| b6b7262962 | |||
| 3ed83913b2 | |||
| 63460f4bf9 | |||
| c67b439752 | |||
| 2b44940f81 | |||
| 26136be903 | |||
| 6a52f69b58 | |||
| 60406c7c2d | |||
| 2465438ec3 | |||
| 99a61580e1 | |||
| dec94b4111 | |||
| ebb97e94a9 | |||
| 5e1f9fadf4 | |||
| fe08de846d | |||
| 35e3c51b75 | |||
| 59c9105c25 | |||
| b458292a69 | |||
| 78aed2cb69 | |||
| 46487b201f | |||
| 939a6a5f4d | |||
| caf0743811 | |||
| 9ccb667653 | |||
| b600f62ab6 | |||
| ace655e164 | |||
| 21ae26cb17 | |||
| 478233f795 | |||
| e87c554ccd | |||
| df33ed05dd | |||
| c9efdd68ed | |||
| 8381945cb5 | |||
| 2046b47739 | |||
| 0c302f088a | |||
| a41db63907 | |||
| 3573c48e98 | |||
| e94980bfd0 | |||
| 5422982207 | |||
| 4fe5497d19 | |||
| 1b549ecc66 | |||
| b5bdba8b16 | |||
| 522c97f5ad | |||
| 7fbb3a5352 | |||
| b3f34529b5 | |||
| d388d07e9f | |||
| c76e27851c | |||
| 8c0dcf3b57 | |||
| 962b3a78c0 | |||
| aa5b941ed5 | |||
| af8a8035e8 | |||
| 037a66c57b | |||
| 1a04dcf10f | |||
| 2eae8b578e | |||
| 17189fce9b | |||
| a0225018e6 | |||
| 361b7aa0da | |||
| 334590932a | |||
| 3f4638204f | |||
| 5e7061b9f6 | |||
| 7a1cd5226f | |||
| 285ac75738 | |||
| 00ff54be4e | |||
| aab35e3faa | |||
| bfa5342331 | |||
| c0d945c0ac | |||
| 22bdc7c20f | |||
| 3ed0081f1f | |||
| 6d0e7650c3 | |||
| 552545fe5f | |||
| dcfe883f4b | |||
| f45fa5e187 | |||
| 05e9da390f | |||
| cc0f8ca813 | |||
| 9c16571347 | |||
| 2765c6ba3b | |||
| 28f3f3c9c9 | |||
| 73d9a95862 | |||
| 9c9a9ac452 | |||
| 29ea396c31 | |||
| 171d215f91 | |||
| cc6109a751 | |||
| 47bb4a9c0f | |||
| b149ea91dd | |||
| 6d1c7d5f57 | |||
| 07bd7503c5 | |||
| 1b5af89ddd | |||
| 3d07dec8fd | |||
| a63bb08eda | |||
| e0207f8167 | |||
| 3099f51ba7 | |||
| 19e7763f35 | |||
| 73cff42ec9 | |||
| b349155f2f | |||
| ab4c120ea5 | |||
| 947133d295 | |||
| bf96e6e642 | |||
| cffacad306 | |||
| cc7b89faf8 | |||
| c1e4746d50 | |||
| 8331eec7fc | |||
| 0547068ed0 | |||
| 18d8389785 | |||
| 165d25d941 | |||
| c4fb77b042 | |||
| 973ea984c8 | |||
| 3e9afe2974 | |||
| 73c16574e6 | |||
| 60e00d49a9 | |||
| 2d22c705ba | |||
| 68d525cd8b | |||
| c3fc1b88fe | |||
| 84b0702399 | |||
| f3489ffa29 | |||
| 8e6ba2a3e1 | |||
| 48e799e7a6 | |||
| bc01999f0d | |||
| b0fcb3065f | |||
| 94d8cd5100 | |||
| 5596c6133b | |||
| 304332e380 | |||
| fb989d8c94 | |||
| 026220b960 | |||
| 543a253bc1 | |||
| 8f8e44e87a | |||
| 2da11097f9 | |||
| d124ebeced | |||
| 986d0e9777 | |||
| f4202361b4 | |||
| 6d981498d8 | |||
| bd2e9917da | |||
| a6810e3353 | |||
| 591eba66a3 | |||
| a5a9ac83e5 | |||
| 15b122a448 | |||
| 44a905d135 | |||
| 8884104e82 | |||
| 277cc5fa21 | |||
| 0cbd7d583c | |||
| 3c3fc92863 | |||
| e69d650598 | |||
| 9385c81882 | |||
| 1b84f9f1ae | |||
| d879fbd8a1 | |||
| 1fbdef06aa | |||
| f5531cc7fa | |||
| 2ccff145ed | |||
| 43b2ee5e71 | |||
| 51463a4b41 | |||
| 4f0116bee7 | |||
| 31793cfa62 | |||
| 6d75540d4e | |||
| ba5cbe208f | |||
| 2b82203041 | |||
| 35da065445 | |||
| 12a1fe3ad4 | |||
| 91057f2a09 | |||
| 15060f00a5 | |||
| 1a82a03d5d | |||
| 4674105698 | |||
| ca3e9a385f | |||
| f05c222221 | |||
| 3dc5fc54df | |||
| bac84b4c8b | |||
| a5b9a80216 | |||
| 142d5e60ec | |||
| 61f947a580 | |||
| c4bbf28862 | |||
| 9befa81e36 | |||
| 414c7ac83d | |||
| 3a612f063e | |||
| 9daea73bba | |||
| 8e8131590c | |||
| 3acfe790b9 | |||
| 877d9120c9 | |||
| c15b88f250 | |||
| 2889e017cd | |||
| 47ea99090f | |||
| 1c1ba04c41 | |||
| 456216ab37 | |||
| 49d7bf8c39 | |||
| dade4cc6f3 | |||
| c747ac181d | |||
| 9837948c3a | |||
| 072fb380d8 | |||
| 85594956cf | |||
| 88eba56607 | |||
| cc6cf48256 | |||
| e571cb553b | |||
| bf9f6e872d | |||
| 8348c1b746 | |||
| 0a9744ac95 | |||
| 95954b7c57 | |||
| a707f81726 | |||
| dae6664555 | |||
| 9dd807344c | |||
| 2ecebf8ff2 | |||
| 6d3cb5f99f | |||
| ec8072d51f | |||
| 7a7bb80e23 | |||
| 99ac5c3045 | |||
| efab00a9de | |||
| 9ab0801ee1 | |||
| cfdb853ea6 | |||
| 41e857ea16 | |||
| 5b2da2b08d | |||
| 5e0a608ea6 | |||
| 3729aefb6f | |||
| 8a2122b4a4 | |||
| cc6f6fdb1d | |||
| 5ec4936a4f | |||
| be84682bcb | |||
| b07f3b4e74 | |||
| fc1f37d3df | |||
| a3f037773a | |||
| c71c8980cf | |||
| 6bf7b79f13 | |||
| 5d9adc14e7 | |||
| 575888d81b | |||
| 3539d3e72d | |||
| bb25111ca9 | |||
| 3c756a65a6 | |||
| 8d574826c9 | |||
| 7c7eebbe83 | |||
| 57ad85814b | |||
| 4b2b419400 | |||
| b83716f0eb | |||
| 6872a4dd7f | |||
| 4d6b2fec13 | |||
| 57c1a7fd69 | |||
| bf78b74db4 | |||
| f80fba4d24 | |||
| d075d2b453 | |||
| 5650624822 | |||
| bf07b0be58 | |||
| eeea53759b | |||
| a39f1e0f9b | |||
| 1614f80366 | |||
| e293c58bb0 | |||
| 3015ebfba1 | |||
| d7da4f5f2b | |||
| c1af6ff2e6 | |||
| aa4000cb0d | |||
| 33128d75f2 | |||
| bf87f37039 | |||
| 62e715ff5b | |||
| b3903175c8 | |||
| de47bd2323 | |||
| 19b55706ee | |||
| 6c68198d19 | |||
| f3c760c25f | |||
| 24fe946c06 | |||
| de6680bdf2 | |||
| 0a28da0cd0 | |||
| a838ff47b5 | |||
| 8bd078caeb | |||
| bce304a800 | |||
| 206d3e7b91 | |||
| 4be32cf746 | |||
| 4ec6075f81 | |||
| aa00e0a6b0 | |||
| bb7fae72c9 | |||
| 7bd19640a2 | |||
| b7271a2a6d | |||
| ecde418abb | |||
| 51036ced9d | |||
| b6c1ec3a24 | |||
| 46004001cb | |||
| f10c8ce25e | |||
| acc370d345 | |||
| 457ab84065 | |||
| 3bcb5452aa | |||
| 1f0e53a44d | |||
| 2d5cf1d3cf | |||
| a81254ed2a | |||
| fdef133d3d | |||
| fd01f0a0ee | |||
| 5b095ed6f3 | |||
| e7a3f34959 | |||
| 06d0c8f056 | |||
| 4064b8ff14 | |||
| 83ecc3d3ac | |||
| 6615eceb18 | |||
| 53f5a37f01 | |||
| bbef2f41ec | |||
| b6e729abeb | |||
| 5fe98689d4 | |||
| 8832a96e82 | |||
| 09631ed119 | |||
| 9257c7ce20 | |||
| b30f9a1677 | |||
| e6c3f96931 | |||
| 85ff81f238 | |||
| 5e0b7f013a | |||
| aa205c6a9f | |||
| 44bfad24a1 | |||
| 13e01841ca | |||
| a999975bc9 | |||
| edf30e1fa1 | |||
| f41bf2082a | |||
| 894d3f1722 | |||
| 83d96e2bbb | |||
| e26ec31463 | |||
| e3bc41dbe6 | |||
| 7a180e22ff | |||
| 3609700b5e | |||
| 389f64df57 | |||
| e85064e4cf | |||
| dd95f8b5cb | |||
| 975487f630 | |||
| 4ba7546c65 | |||
| c97aa55163 | |||
| 2e1e30705a | |||
| c92ac809a5 | |||
| ec842e8d51 | |||
| 6d6e3900c3 | |||
| 0516a0d7a6 | |||
| adbbe158db | |||
| 6d2be4a305 | |||
| 78c9a5d45b | |||
| 5fa1645165 | |||
| bbf6ec0458 | |||
| e58b20f68d | |||
| 0ce697daba | |||
| a2dfadc6c8 | |||
| 6df8b3fe72 | |||
| b623adc6df | |||
| 2f77da7813 | |||
| 9897c99190 | |||
| aebc30447f | |||
| d2bae54ed0 | |||
| 501c369f39 | |||
| db3468a815 | |||
| 3aabed44ce | |||
| 3af7a6b082 | |||
| 2e985198c6 | |||
| 74a2ef8138 | |||
| 88ea21b276 | |||
| 62397dbd0b | |||
| 317b086f66 | |||
| 12340c1d10 | |||
| e747199711 | |||
| df7ce883c7 | |||
| eb3e2dca24 | |||
| 2d9b936b0a | |||
| 66c7aca2f6 | |||
| 0c3344d0c4 | |||
| 0ac211140a | |||
| 5d490664ca | |||
| d170dd305d | |||
| b50bd58795 | |||
| 1da279a290 | |||
| 100b9a470b | |||
| 43c2b36eaa | |||
| 203d0bd8ae | |||
| 14092fbadb | |||
| 35ad76771d | |||
| 96151c44aa | |||
| 02dcb01120 | |||
| 51d25e5859 | |||
| b8535689d3 | |||
| 8ff890635f | |||
| 29b6ba0758 | |||
| ca5793dbea | |||
| 0fdaa8e745 | |||
| 5a71044d5a | |||
| 8d091051af | |||
| 34da1ef9d6 | |||
| e31e35c46b |
@@ -7,33 +7,41 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!--
|
<!-- Hey there, thank you for creating an issue! -->
|
||||||
Hey there, thanks for creating an issue!
|
|
||||||
|
|
||||||
In order to reproduce your issue, we might need to know a little bit more about the environment
|
|
||||||
which you're running `bat` on.
|
|
||||||
|
|
||||||
If you're on Linux or MacOS:
|
|
||||||
Please run the script at https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh and
|
|
||||||
paste the output at the bottom of the bug report.
|
|
||||||
|
|
||||||
If you're on Windows:
|
|
||||||
Please tell us about your Windows Version (e.g. "Windows 10 1908") at the
|
|
||||||
bottom of the bug report.
|
|
||||||
-->
|
|
||||||
|
|
||||||
**What version of `bat` are you using?**
|
|
||||||
[paste the output of `bat --version` here]
|
|
||||||
|
|
||||||
**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. -->
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[paste the output of `info.sh` here]
|
**bat version and environment**
|
||||||
|
|
||||||
|
<!--
|
||||||
|
In order to reproduce your issue, please add some information about the environment
|
||||||
|
in which you're running bat. To do this, run the full `bat` command that demonstrates
|
||||||
|
the bug, and attach the `--diagnostic` option:
|
||||||
|
|
||||||
|
bat [other options and arguments…] --diagnostic
|
||||||
|
|
||||||
|
Finally, paste the Markdown output here. Please make sure that it does not reveal any
|
||||||
|
personal information.
|
||||||
|
|
||||||
|
|
||||||
|
If you are running bat 0.17.1 or older (where --diagnostic is not available), please
|
||||||
|
run the script at
|
||||||
|
|
||||||
|
https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh
|
||||||
|
|
||||||
|
(click "Raw" to get the actual source code) and paste the Markdown output here. If you
|
||||||
|
are on Windows, please let us know your bat version and your Windows version.
|
||||||
|
-->
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: cargo
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
||||||
|
time: "04:00"
|
||||||
|
timezone: Europe/Berlin
|
||||||
|
ignore:
|
||||||
|
- dependency-name: git2
|
||||||
|
versions:
|
||||||
|
- 0.13.17
|
||||||
|
- package-ecosystem: gitsubmodule
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: monthly
|
||||||
|
time: "04:00"
|
||||||
|
timezone: Europe/Berlin
|
||||||
+280
-313
@@ -1,38 +1,49 @@
|
|||||||
name: CICD
|
name: CICD
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PROJECT_NAME: bat
|
MIN_SUPPORTED_RUST_VERSION: "1.45.0"
|
||||||
PROJECT_DESC: "A `cat` clone with wings"
|
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
|
||||||
PROJECT_MAINTAINER: "David Peter <mail@david-peter.de>"
|
|
||||||
PROJECT_HOMEPAGE: "https://github.com/sharkdp/bat"
|
|
||||||
MIN_SUPPORTED_RUST_VERSION: "1.40.0"
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
min_version:
|
min_version:
|
||||||
name: Minimum supported rust version
|
name: Minimum supported rust version
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: Git checkout
|
- name: Checkout source code
|
||||||
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:
|
||||||
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
||||||
default: true
|
default: true
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
profile: minimal # minimal component installation (ie, no documentation)
|
||||||
- name: Test
|
components: clippy
|
||||||
|
- name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: --all-targets --all-features
|
||||||
|
- name: Run tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
|
||||||
test_with_new_syntaxes_and_themes:
|
test_with_new_syntaxes_and_themes:
|
||||||
name: Test with new syntaxes and themes
|
name: Run tests with updated syntaxes and themes
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-18.04
|
||||||
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,36 +69,47 @@ 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
|
||||||
run: bat --list-languages
|
run: bat --list-languages
|
||||||
- name: List of themes
|
- name: List of themes
|
||||||
run: bat --list-themes
|
run: bat --list-themes
|
||||||
|
- name: Check documentation
|
||||||
|
env:
|
||||||
|
RUSTDOCFLAGS: -D warnings
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: doc
|
||||||
|
args: --no-deps --document-private-items --all-features
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: ${{ matrix.job.os }} (${{ matrix.job.target }})
|
||||||
runs-on: ${{ matrix.job.os }}
|
runs-on: ${{ matrix.job.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
job:
|
job:
|
||||||
# { os, target, cargo-options, features, use-cross, toolchain }
|
- { os: ubuntu-18.04, target: arm-unknown-linux-gnueabihf , use-cross: true }
|
||||||
- { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , use-cross: use-cross }
|
- { os: ubuntu-18.04, target: aarch64-unknown-linux-gnu , use-cross: true }
|
||||||
- { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: use-cross }
|
- { os: ubuntu-18.04, target: i686-unknown-linux-gnu , use-cross: true }
|
||||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: use-cross }
|
- { os: ubuntu-18.04, target: i686-unknown-linux-musl , use-cross: true }
|
||||||
- { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: use-cross }
|
- { os: ubuntu-18.04, target: x86_64-unknown-linux-gnu }
|
||||||
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu , use-cross: use-cross }
|
- { os: ubuntu-18.04, target: x86_64-unknown-linux-musl , use-cross: true }
|
||||||
- { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: use-cross }
|
- { os: macos-10.15 , target: x86_64-apple-darwin }
|
||||||
- { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu , use-cross: use-cross }
|
# - { os: windows-2019, target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
|
||||||
- { os: macos-latest , target: x86_64-apple-darwin }
|
- { os: windows-2019, target: i686-pc-windows-msvc }
|
||||||
# - { os: windows-latest , target: i686-pc-windows-gnu } ## disabled; linker errors (missing '_imp____acrt_iob_func')
|
- { os: windows-2019, target: x86_64-pc-windows-gnu }
|
||||||
- { os: windows-latest , target: i686-pc-windows-msvc }
|
- { os: windows-2019, target: x86_64-pc-windows-msvc }
|
||||||
# - { os: windows-latest , target: x86_64-pc-windows-gnu } ## disabled; linker errors (missing '_imp____acrt_iob_func')
|
|
||||||
- { os: windows-latest , target: x86_64-pc-windows-msvc }
|
|
||||||
steps:
|
steps:
|
||||||
- name: Git checkout
|
- name: Checkout source code
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -95,121 +117,24 @@ jobs:
|
|||||||
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
arm-unknown-linux-gnueabihf) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
||||||
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
|
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
|
||||||
esac
|
esac
|
||||||
- name: Initialize workflow variables
|
|
||||||
id: vars
|
- name: Extract crate information
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# toolchain
|
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
|
||||||
TOOLCHAIN="stable" ## default to "stable" toolchain
|
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
|
||||||
# * specify alternate TOOLCHAIN for *-pc-windows-gnu targets; gnu targets on Windows are broken for the standard *-pc-windows-msvc toolchain (refs: <https://github.com/rust-lang/rust/issues/47048>, <https://github.com/rust-lang/rust/issues/53454>, <https://github.com/rust-lang/cargo/issues/6754>)
|
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
|
||||||
case ${{ matrix.job.target }} in *-pc-windows-gnu) TOOLCHAIN="stable-${{ matrix.job.target }}" ;; esac;
|
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
|
||||||
# * use requested TOOLCHAIN if specified
|
|
||||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
|
||||||
echo set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
echo ::set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
# staging directory
|
|
||||||
STAGING='_staging'
|
|
||||||
echo set-output name=STAGING::${STAGING}
|
|
||||||
echo ::set-output name=STAGING::${STAGING}
|
|
||||||
# determine EXE suffix
|
|
||||||
EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
|
|
||||||
echo set-output name=EXE_suffix::${EXE_suffix}
|
|
||||||
echo ::set-output name=EXE_suffix::${EXE_suffix}
|
|
||||||
# parse commit reference info
|
|
||||||
REF_NAME=${GITHUB_REF#refs/*/}
|
|
||||||
unset REF_BRANCH ; case ${GITHUB_REF} in refs/heads/*) REF_BRANCH=${GITHUB_REF#refs/heads/} ;; esac;
|
|
||||||
unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
|
|
||||||
REF_SHAS=${GITHUB_SHA:0:8}
|
|
||||||
echo set-output name=REF_NAME::${REF_NAME}
|
|
||||||
echo set-output name=REF_BRANCH::${REF_BRANCH}
|
|
||||||
echo set-output name=REF_TAG::${REF_TAG}
|
|
||||||
echo set-output name=REF_SHAS::${REF_SHAS}
|
|
||||||
echo ::set-output name=REF_NAME::${REF_NAME}
|
|
||||||
echo ::set-output name=REF_BRANCH::${REF_BRANCH}
|
|
||||||
echo ::set-output name=REF_TAG::${REF_TAG}
|
|
||||||
echo ::set-output name=REF_SHAS::${REF_SHAS}
|
|
||||||
# parse target
|
|
||||||
unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
|
|
||||||
echo set-output name=TARGET_ARCH::${TARGET_ARCH}
|
|
||||||
echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
|
|
||||||
unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
|
|
||||||
echo set-output name=TARGET_OS::${TARGET_OS}
|
|
||||||
echo ::set-output name=TARGET_OS::${TARGET_OS}
|
|
||||||
# package name
|
|
||||||
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
|
|
||||||
PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }}
|
|
||||||
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
|
|
||||||
echo set-output name=PKG_suffix::${PKG_suffix}
|
|
||||||
echo set-output name=PKG_BASENAME::${PKG_BASENAME}
|
|
||||||
echo set-output name=PKG_NAME::${PKG_NAME}
|
|
||||||
echo ::set-output name=PKG_suffix::${PKG_suffix}
|
|
||||||
echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
|
|
||||||
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
|
||||||
# deployable tag? (ie, leading "vM" or "M"; M == version number)
|
|
||||||
unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
|
|
||||||
echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
|
|
||||||
echo ::set-output name=DEPLOY::${DEPLOY}
|
|
||||||
# DPKG architecture?
|
|
||||||
unset DPKG_ARCH
|
|
||||||
case ${{ matrix.job.target }} in
|
|
||||||
aarch64-*-linux-*) DPKG_ARCH=arm64 ;;
|
|
||||||
arm-*-linux-*hf) DPKG_ARCH=armhf ;;
|
|
||||||
i686-*-linux-*) DPKG_ARCH=i686 ;;
|
|
||||||
x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
|
|
||||||
esac;
|
|
||||||
echo set-output name=DPKG_ARCH::${DPKG_ARCH}
|
|
||||||
echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
|
|
||||||
# DPKG version?
|
|
||||||
unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
|
|
||||||
echo set-output name=DPKG_VERSION::${DPKG_VERSION}
|
|
||||||
echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
|
|
||||||
# DPKG base name/conflicts?
|
|
||||||
DPKG_BASENAME=${PROJECT_NAME}
|
|
||||||
DPKG_CONFLICTS=${PROJECT_NAME}-musl
|
|
||||||
case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;
|
|
||||||
echo set-output name=DPKG_BASENAME::${DPKG_BASENAME}
|
|
||||||
echo set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
|
|
||||||
echo ::set-output name=DPKG_BASENAME::${DPKG_BASENAME}
|
|
||||||
echo ::set-output name=DPKG_CONFLICTS::${DPKG_CONFLICTS}
|
|
||||||
# DPKG name
|
|
||||||
unset DPKG_NAME;
|
|
||||||
if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
|
|
||||||
echo set-output name=DPKG_NAME::${DPKG_NAME}
|
|
||||||
echo ::set-output name=DPKG_NAME::${DPKG_NAME}
|
|
||||||
# target-specific options
|
|
||||||
# * CARGO_USE_CROSS (truthy)
|
|
||||||
CARGO_USE_CROSS='true' ; case '${{ matrix.job.use-cross }}' in ''|0|f|false|n|no) unset CARGO_USE_CROSS ;; esac;
|
|
||||||
echo set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS:-<empty>/false}
|
|
||||||
echo ::set-output name=CARGO_USE_CROSS::${CARGO_USE_CROSS}
|
|
||||||
# # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
|
|
||||||
JOB_DO_TESTING="true"
|
|
||||||
case ${{ matrix.job.target }} in arm-*) unset JOB_DO_TESTING ;; esac;
|
|
||||||
echo set-output name=JOB_DO_TESTING::${JOB_DO_TESTING:-<empty>/false}
|
|
||||||
echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
|
|
||||||
# # * test only library unit tests and binary for arm-type targets
|
|
||||||
unset CARGO_TEST_OPTIONS
|
|
||||||
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac;
|
|
||||||
echo set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
|
||||||
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
|
||||||
# * executable for `strip`?
|
|
||||||
STRIP="strip" ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;; aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;; *-pc-windows-msvc) STRIP="" ;; esac;
|
|
||||||
echo set-output name=STRIP::${STRIP}
|
|
||||||
echo ::set-output name=STRIP::${STRIP}
|
|
||||||
- name: Create all needed build/work directories
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}'
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}'
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/autocomplete'
|
|
||||||
mkdir -p '${{ steps.vars.outputs.STAGING }}/dpkg'
|
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
|
toolchain: stable
|
||||||
target: ${{ matrix.job.target }}
|
target: ${{ matrix.job.target }}
|
||||||
override: true
|
override: true
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
profile: minimal # minimal component installation (ie, no documentation)
|
||||||
- name: Info
|
|
||||||
|
- name: Show version information (Rust, cargo, GCC)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
gcc --version || true
|
gcc --version || true
|
||||||
@@ -218,63 +143,124 @@ jobs:
|
|||||||
rustup default
|
rustup default
|
||||||
cargo -V
|
cargo -V
|
||||||
rustc -V
|
rustc -V
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
command: build
|
command: build
|
||||||
args: --release --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }}
|
args: --release --target=${{ matrix.job.target }}
|
||||||
- name: Test
|
|
||||||
uses: actions-rs/cargo@v1
|
- name: Strip debug information from executable
|
||||||
with:
|
id: strip
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: test
|
|
||||||
args: --target=${{ matrix.job.target }} ${{ steps.vars.outputs.CARGO_TEST_OPTIONS}} ${{ matrix.job.cargo-options }}
|
|
||||||
- name: bat test run
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: run
|
|
||||||
args: --target=${{ matrix.job.target }} ${{ matrix.job.cargo-options }} -- --paging=never --color=always --theme=ansi-dark Cargo.toml src/config.rs
|
|
||||||
- name: Check features regex-onig
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: check
|
|
||||||
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig
|
|
||||||
- name: Check features regex-onig,git
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: check
|
|
||||||
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git
|
|
||||||
- name: Check features regex-onig,paging
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: check
|
|
||||||
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,paging
|
|
||||||
- name: Check features regex-onig,git,paging
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
use-cross: ${{ steps.vars.outputs.CARGO_USE_CROSS }}
|
|
||||||
command: check
|
|
||||||
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git,paging
|
|
||||||
- name: Upload build artifacts
|
|
||||||
uses: actions/upload-artifact@master
|
|
||||||
with:
|
|
||||||
name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
|
|
||||||
path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
|
|
||||||
- name: Package
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
ARCHIVE_DIR='${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
|
# Figure out suffix of binary
|
||||||
COPYRIGHT_YEARS="2018 - "$(date "+%Y")
|
EXE_suffix=""
|
||||||
# Binary
|
case ${{ matrix.job.target }} in
|
||||||
cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "$ARCHIVE_DIR"
|
*-pc-windows-*) EXE_suffix=".exe" ;;
|
||||||
|
esac;
|
||||||
|
|
||||||
# `strip` binary (if needed)
|
# Figure out what strip tool to use if any
|
||||||
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "$ARCHIVE_DIR/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
|
STRIP="strip"
|
||||||
|
case ${{ matrix.job.target }} in
|
||||||
|
arm-unknown-linux-gnueabihf) STRIP="arm-linux-gnueabihf-strip" ;;
|
||||||
|
aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
|
||||||
|
*-pc-windows-msvc) STRIP="" ;;
|
||||||
|
esac;
|
||||||
|
|
||||||
|
# Setup paths
|
||||||
|
BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"
|
||||||
|
mkdir -p "${BIN_DIR}"
|
||||||
|
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
|
||||||
|
BIN_PATH="${BIN_DIR}/${BIN_NAME}"
|
||||||
|
|
||||||
|
# Copy the release build binary to the result location
|
||||||
|
cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"
|
||||||
|
|
||||||
|
# Also strip if possible
|
||||||
|
if [ -n "${STRIP}" ]; then
|
||||||
|
"${STRIP}" "${BIN_PATH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Let subsequent steps know where to find the (stripped) bin
|
||||||
|
echo ::set-output name=BIN_PATH::${BIN_PATH}
|
||||||
|
echo ::set-output name=BIN_NAME::${BIN_NAME}
|
||||||
|
|
||||||
|
- name: Set testing options
|
||||||
|
id: test-options
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# test only library unit tests and binary for arm-type targets
|
||||||
|
unset CARGO_TEST_OPTIONS
|
||||||
|
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac;
|
||||||
|
echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: test
|
||||||
|
args: --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
|
||||||
|
|
||||||
|
- name: Run bat
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: run
|
||||||
|
args: --target=${{ matrix.job.target }} -- --paging=never --color=always --theme=ansi Cargo.toml src/config.rs
|
||||||
|
|
||||||
|
- name: Show diagnostics (bat --diagnostic)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: run
|
||||||
|
args: --target=${{ matrix.job.target }} -- --paging=never --color=always --theme=ansi Cargo.toml src/config.rs --diagnostic
|
||||||
|
|
||||||
|
- name: "Feature check: regex-onig"
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: check
|
||||||
|
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig
|
||||||
|
|
||||||
|
- name: "Feature check: regex-onig,git"
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: check
|
||||||
|
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git
|
||||||
|
|
||||||
|
- name: "Feature check: regex-onig,paging"
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: check
|
||||||
|
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,paging
|
||||||
|
|
||||||
|
- name: "Feature check: regex-onig,git,paging"
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
use-cross: ${{ matrix.job.use-cross }}
|
||||||
|
command: check
|
||||||
|
args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git,paging
|
||||||
|
|
||||||
|
- name: Create tarball
|
||||||
|
id: package
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
|
||||||
|
PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
|
||||||
|
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
|
||||||
|
echo ::set-output name=PKG_NAME::${PKG_NAME}
|
||||||
|
|
||||||
|
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
|
||||||
|
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
|
||||||
|
mkdir -p "${ARCHIVE_DIR}"
|
||||||
|
mkdir -p "${ARCHIVE_DIR}/autocomplete"
|
||||||
|
|
||||||
|
# Binary
|
||||||
|
cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
|
||||||
|
|
||||||
# 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"
|
||||||
@@ -283,53 +269,67 @@ jobs:
|
|||||||
cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"
|
cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"
|
||||||
|
|
||||||
# Autocompletion files
|
# Autocompletion files
|
||||||
|
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.bash "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.bash"
|
||||||
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"
|
||||||
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.zsh"
|
cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.zsh"
|
||||||
|
|
||||||
# base compressed package
|
# base compressed package
|
||||||
pushd '${{ steps.vars.outputs.STAGING }}/' >/dev/null
|
pushd "${PKG_STAGING}/" >/dev/null
|
||||||
case ${{ matrix.job.target }} in
|
case ${{ matrix.job.target }} in
|
||||||
*-pc-windows-*) 7z -y a '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* | tail -2 ;;
|
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
|
||||||
*) tar czf '${{ steps.vars.outputs.PKG_NAME }}' '${{ steps.vars.outputs.PKG_BASENAME }}'/* ;;
|
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
|
||||||
esac;
|
esac;
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
# Debian package
|
# Let subsequent steps know where to find the compressed package
|
||||||
if [ -n "${{ steps.vars.outputs.DPKG_NAME }}" ]; then
|
echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}"
|
||||||
DPKG_DIR="${{ steps.vars.outputs.STAGING }}/dpkg"
|
|
||||||
|
|
||||||
# Binary
|
- name: Create Debian package
|
||||||
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 }}"
|
id: debian-package
|
||||||
if [ -n "${{ steps.vars.outputs.STRIP }}" ]; then "${{ steps.vars.outputs.STRIP }}" "${DPKG_DIR}/usr/bin/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}" ; fi
|
shell: bash
|
||||||
|
if: startsWith(matrix.job.os, 'ubuntu')
|
||||||
|
run: |
|
||||||
|
COPYRIGHT_YEARS="2018 - "$(date "+%Y")
|
||||||
|
DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package"
|
||||||
|
DPKG_DIR="${DPKG_STAGING}/dpkg"
|
||||||
|
mkdir -p "${DPKG_DIR}"
|
||||||
|
|
||||||
# Work out shared library dependencies
|
DPKG_BASENAME=${PROJECT_NAME}
|
||||||
# dpkg-shlibdeps requires debian/control file. Dummy it and clean up
|
DPKG_CONFLICTS=${PROJECT_NAME}-musl
|
||||||
mkdir "./debian"
|
case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${PROJECT_NAME}-musl ; DPKG_CONFLICTS=${PROJECT_NAME} ;; esac;
|
||||||
touch "./debian/control"
|
DPKG_VERSION=${PROJECT_VERSION}
|
||||||
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
|
unset DPKG_ARCH
|
||||||
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"
|
case ${{ matrix.job.target }} in
|
||||||
gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
|
aarch64-*-linux-*) DPKG_ARCH=arm64 ;;
|
||||||
|
arm-*-linux-*hf) DPKG_ARCH=armhf ;;
|
||||||
|
i686-*-linux-*) DPKG_ARCH=i686 ;;
|
||||||
|
x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
|
||||||
|
*) DPKG_ARCH=notset ;;
|
||||||
|
esac;
|
||||||
|
|
||||||
# Autocompletion files
|
DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb"
|
||||||
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"
|
echo ::set-output name=DPKG_NAME::${DPKG_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
|
# Binary
|
||||||
install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/README.md"
|
install -Dm755 "${{ steps.strip.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.strip.outputs.BIN_NAME }}"
|
||||||
install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/LICENSE-MIT"
|
|
||||||
install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/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
|
# 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"
|
||||||
|
gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
|
||||||
|
|
||||||
|
# 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.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"
|
||||||
|
|
||||||
|
# README and LICENSE
|
||||||
|
install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md"
|
||||||
|
install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT"
|
||||||
|
install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE"
|
||||||
|
install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"
|
||||||
|
gzip -n --best "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/changelog"
|
||||||
|
|
||||||
|
cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/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 }}
|
||||||
@@ -340,117 +340,84 @@ jobs:
|
|||||||
License: Apache-2.0 or MIT
|
License: Apache-2.0 or MIT
|
||||||
|
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
On Debian systems, the complete text of the Apache-2.0 can be found in the
|
On Debian systems, the complete text of the Apache-2.0 can be found in the
|
||||||
file /usr/share/common-licenses/Apache-2.0.
|
file /usr/share/common-licenses/Apache-2.0.
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
Permission is hereby granted, free of charge, to any
|
Permission is hereby granted, free of charge, to any
|
||||||
person obtaining a copy of this software and associated
|
person obtaining a copy of this software and associated
|
||||||
documentation files (the "Software"), to deal in the
|
documentation files (the "Software"), to deal in the
|
||||||
Software without restriction, including without
|
Software without restriction, including without
|
||||||
limitation the rights to use, copy, modify, merge,
|
limitation the rights to use, copy, modify, merge,
|
||||||
publish, distribute, sublicense, and/or sell copies of
|
publish, distribute, sublicense, and/or sell copies of
|
||||||
the Software, and to permit persons to whom the Software
|
the Software, and to permit persons to whom the Software
|
||||||
is furnished to do so, subject to the following
|
is furnished to do so, subject to the following
|
||||||
conditions:
|
conditions:
|
||||||
.
|
.
|
||||||
The above copyright notice and this permission notice
|
The above copyright notice and this permission notice
|
||||||
shall be included in all copies or substantial portions
|
shall be included in all copies or substantial portions
|
||||||
of the Software.
|
of the Software.
|
||||||
.
|
.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||||
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"
|
chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright"
|
||||||
|
|
||||||
# control file
|
# control file
|
||||||
mkdir -p "${DPKG_DIR}/DEBIAN"
|
mkdir -p "${DPKG_DIR}/DEBIAN"
|
||||||
cat > "${DPKG_DIR}/DEBIAN/control" <<EOF
|
cat > "${DPKG_DIR}/DEBIAN/control" <<EOF
|
||||||
Package: ${{ steps.vars.outputs.DPKG_BASENAME }}
|
Package: ${DPKG_BASENAME}
|
||||||
Version: ${{ steps.vars.outputs.DPKG_VERSION }}
|
Version: ${DPKG_VERSION}
|
||||||
Section: utils
|
Section: utils
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Maintainer: ${{ env.PROJECT_MAINTAINER }}
|
Maintainer: ${{ env.PROJECT_MAINTAINER }}
|
||||||
Homepage: ${{ env.PROJECT_HOMEPAGE }}
|
Homepage: ${{ env.PROJECT_HOMEPAGE }}
|
||||||
Architecture: ${{ steps.vars.outputs.DPKG_ARCH }}
|
Architecture: ${DPKG_ARCH}
|
||||||
Depends: $DEPENDS
|
|
||||||
Provides: ${{ env.PROJECT_NAME }}
|
Provides: ${{ env.PROJECT_NAME }}
|
||||||
Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}
|
Conflicts: ${DPKG_CONFLICTS}
|
||||||
Description: cat(1) clone with wings.
|
Description: 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
|
||||||
|
|
||||||
# build dpkg
|
DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}"
|
||||||
fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
|
echo ::set-output name=DPKG_PATH::${DPKG_PATH}
|
||||||
fi
|
|
||||||
- name: Publish archives and packages
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: steps.vars.outputs.DEPLOY
|
|
||||||
with:
|
|
||||||
files: |
|
|
||||||
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
|
|
||||||
${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
coverage:
|
# build dpkg
|
||||||
name: Code Coverage
|
fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}"
|
||||||
runs-on: ${{ matrix.job.os }}
|
|
||||||
strategy:
|
- name: "Artifact upload: tarball"
|
||||||
fail-fast: true
|
uses: actions/upload-artifact@master
|
||||||
matrix:
|
with:
|
||||||
# job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ]
|
name: ${{ steps.package.outputs.PKG_NAME }}
|
||||||
job:
|
path: ${{ steps.package.outputs.PKG_PATH }}
|
||||||
- { os: ubuntu-latest , toolchain: nightly-2020-04-29 }
|
|
||||||
- { os: macos-latest , toolchain: nightly-2020-04-29 }
|
- name: "Artifact upload: Debian package"
|
||||||
- { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
|
uses: actions/upload-artifact@master
|
||||||
steps:
|
if: steps.debian-package.outputs.DPKG_NAME
|
||||||
- uses: actions/checkout@v1
|
with:
|
||||||
- name: Initialize workflow variables
|
name: ${{ steps.debian-package.outputs.DPKG_NAME }}
|
||||||
id: vars
|
path: ${{ steps.debian-package.outputs.DPKG_PATH }}
|
||||||
|
|
||||||
|
- name: Check for release
|
||||||
|
id: is-release
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# toolchain
|
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
|
||||||
TOOLCHAIN="nightly" ## default to "nightly" toolchain
|
echo ::set-output name=IS_RELEASE::${IS_RELEASE}
|
||||||
# * use requested TOOLCHAIN if specified
|
|
||||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
- name: Publish archives and packages
|
||||||
# * use requested TOOLCHAIN if specified
|
uses: softprops/action-gh-release@v1
|
||||||
if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
|
if: steps.is-release.outputs.IS_RELEASE
|
||||||
echo set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
echo ::set-output name=TOOLCHAIN::${TOOLCHAIN}
|
|
||||||
# target-specific options
|
|
||||||
# * CODECOV_FLAGS
|
|
||||||
CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
|
|
||||||
echo set-output name=CODECOV_FLAGS::${CODECOV_FLAGS}
|
|
||||||
echo ::set-output name=CODECOV_FLAGS::${CODECOV_FLAGS}
|
|
||||||
- name: rust toolchain ~ install
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ steps.vars.outputs.TOOLCHAIN }}
|
files: |
|
||||||
override: true
|
${{ steps.package.outputs.PKG_PATH }}
|
||||||
profile: minimal # minimal component installation (ie, no documentation)
|
${{ steps.debian-package.outputs.DPKG_PATH }}
|
||||||
- name: Test
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: test
|
|
||||||
args: --no-fail-fast
|
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: '0'
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads'
|
|
||||||
- name: Generate coverage data
|
|
||||||
id: coverage
|
|
||||||
uses: actions-rs/grcov@v0.1
|
|
||||||
- name: Upload coverage results (to Codecov.io)
|
|
||||||
uses: codecov/codecov-action@v1
|
|
||||||
with:
|
|
||||||
file: ${{ steps.coverage.outputs.report }}
|
|
||||||
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
|
|
||||||
name: codecov-umbrella
|
|
||||||
fail_ci_if_error: false
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
# Generated files
|
# Generated files
|
||||||
|
/assets/completions/bat.bash
|
||||||
/assets/completions/bat.fish
|
/assets/completions/bat.fish
|
||||||
/assets/completions/bat.zsh
|
/assets/completions/bat.zsh
|
||||||
/assets/manual/bat.1
|
/assets/manual/bat.1
|
||||||
|
|||||||
+31
-10
@@ -61,9 +61,6 @@
|
|||||||
[submodule "assets/syntaxes/Puppet"]
|
[submodule "assets/syntaxes/Puppet"]
|
||||||
path = assets/syntaxes/02_Extra/Puppet
|
path = assets/syntaxes/02_Extra/Puppet
|
||||||
url = https://github.com/russCloak/SublimePuppet
|
url = https://github.com/russCloak/SublimePuppet
|
||||||
[submodule "assets/syntaxes/CSV"]
|
|
||||||
path = assets/syntaxes/02_Extra/CSV
|
|
||||||
url = https://github.com/wadetb/Sublime-Text-Advanced-CSV
|
|
||||||
[submodule "assets/themes/onehalf"]
|
[submodule "assets/themes/onehalf"]
|
||||||
path = assets/themes/onehalf
|
path = assets/themes/onehalf
|
||||||
url = https://github.com/sonph/onehalf
|
url = https://github.com/sonph/onehalf
|
||||||
@@ -97,10 +94,6 @@
|
|||||||
[submodule "assets/syntaxes/Assembly (ARM)"]
|
[submodule "assets/syntaxes/Assembly (ARM)"]
|
||||||
path = assets/syntaxes/02_Extra/Assembly (ARM)
|
path = assets/syntaxes/02_Extra/Assembly (ARM)
|
||||||
url = https://github.com/tvi/Sublime-ARM-Assembly
|
url = https://github.com/tvi/Sublime-ARM-Assembly
|
||||||
[submodule "assets/syntaxes/syslog-syntax"]
|
|
||||||
path = assets/syntaxes/02_Extra/Syslog
|
|
||||||
url = https://github.com/caos21/syslog-syntax.git
|
|
||||||
branch = master
|
|
||||||
[submodule "assets/syntaxes/protobuf-syntax-highlighting"]
|
[submodule "assets/syntaxes/protobuf-syntax-highlighting"]
|
||||||
path = assets/syntaxes/02_Extra/Protobuf
|
path = assets/syntaxes/02_Extra/Protobuf
|
||||||
url = https://github.com/VcamX/protobuf-syntax-highlighting.git
|
url = https://github.com/VcamX/protobuf-syntax-highlighting.git
|
||||||
@@ -185,9 +178,6 @@
|
|||||||
[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
|
[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
|
||||||
path = assets/syntaxes/02_Extra/AsciiDoc
|
path = assets/syntaxes/02_Extra/AsciiDoc
|
||||||
url = https://github.com/asciidoctor/sublimetext-asciidoc.git
|
url = https://github.com/asciidoctor/sublimetext-asciidoc.git
|
||||||
[submodule "assets/themes/gruvbox"]
|
|
||||||
path = assets/themes/gruvbox
|
|
||||||
url = https://github.com/peaceant/gruvbox.git
|
|
||||||
[submodule "assets/syntaxes/02_Extra/GLSL"]
|
[submodule "assets/syntaxes/02_Extra/GLSL"]
|
||||||
path = assets/syntaxes/02_Extra/GLSL
|
path = assets/syntaxes/02_Extra/GLSL
|
||||||
url = https://github.com/euler0/sublime-glsl
|
url = https://github.com/euler0/sublime-glsl
|
||||||
@@ -197,3 +187,34 @@
|
|||||||
[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
|
||||||
|
[submodule "assets/themes/gruvbox"]
|
||||||
|
path = assets/themes/gruvbox
|
||||||
|
url = https://github.com/subnut/gruvbox-tmTheme.git
|
||||||
|
branch = bat-source
|
||||||
|
[submodule "assets/syntaxes/02_Extra/Lean"]
|
||||||
|
path = assets/syntaxes/02_Extra/Lean
|
||||||
|
url = https://github.com/leanprover/vscode-lean.git
|
||||||
|
[submodule "assets/syntaxes/02_Extra/Zig"]
|
||||||
|
path = assets/syntaxes/02_Extra/Zig
|
||||||
|
url = https://github.com/ziglang/sublime-zig-language.git
|
||||||
|
[submodule "assets/syntaxes/02_Extra/gnuplot"]
|
||||||
|
path = assets/syntaxes/02_Extra/gnuplot
|
||||||
|
url = https://github.com/hesstobi/sublime_gnuplot
|
||||||
|
[submodule "assets/syntaxes/02_Extra/SystemVerilog"]
|
||||||
|
path = assets/syntaxes/02_Extra/SystemVerilog
|
||||||
|
url = https://github.com/TheClams/SystemVerilog.git
|
||||||
|
[submodule "assets/themes/visual-studio-dark-plus"]
|
||||||
|
path = assets/themes/visual-studio-dark-plus
|
||||||
|
url = https://github.com/vidann1/visual-studio-dark-plus.git
|
||||||
|
[submodule "assets/syntaxes/02_Extra/SublimeEthereum"]
|
||||||
|
path = assets/syntaxes/02_Extra/SublimeEthereum
|
||||||
|
url = https://github.com/davidhq/SublimeEthereum.git
|
||||||
+141
-2
@@ -2,17 +2,156 @@
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
|
||||||
|
|
||||||
## Syntaxes
|
## Syntaxes
|
||||||
|
|
||||||
|
|
||||||
## New themes
|
## New themes
|
||||||
|
|
||||||
|
|
||||||
## `bat` as a library
|
## `bat` as a library
|
||||||
|
|
||||||
## Packaging
|
|
||||||
|
|
||||||
|
|
||||||
|
# v0.18.2
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Ignore known backup/template filename suffixes when selecting the syntax, see #1687 (@scop)
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- Fix for a security vulnerability on Windows. Prior to this release, `bat` would execute programs called `less`/`less.exe` from the current working directory (instead of the one from `PATH`) with priority. An attacker might be able to use this by placing a malicious program in a shared directory where the user would execute `bat`. `bat` users on Windows are advised to upgrade to this version. See #1724 and #1472 (@Ry0taK).
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
- Add bash completion, see #1678 (@scop)
|
||||||
|
- Fix Clippy lints, see #1661 (@mohamed-abdelnour)
|
||||||
|
- Add syntax highlighting test files, see #1213 and #1668 (@mohamed-abdelnour)
|
||||||
|
|
||||||
|
## Syntaxes
|
||||||
|
|
||||||
|
- Upgraded Julia syntax to fix a highlighting bug, see #1692
|
||||||
|
- Added support for `dash` syntax, see #1654 (@mohamed-abdelnour)
|
||||||
|
- Added support for `XAML` syntax, see #1590 and #1655 (@mohamed-abdelnour)
|
||||||
|
- Apply `DotENV` syntax also for `.env.default` and `.env.defaults` files, see #1669
|
||||||
|
|
||||||
|
|
||||||
|
# v0.18.1
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- Mouse support and screen clearing broken for `less` versions with minor version number (581.2), see #1629 and #1639 (@aswild)
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
- `Input::ordinary_file` and `Input::with_name` now accept `Path` rather than `OsStr` see #1571 (@matklad)
|
||||||
|
- The `LESS` environment variable is now included in `bat --diagnostic`, see #1589 (@Enselic)
|
||||||
|
- Increased min. required Rust version to 1.45
|
||||||
|
|
||||||
|
## Syntaxes
|
||||||
|
|
||||||
|
- Improved the Syslog syntax highlighting, see #1606 (@keith-hall)
|
||||||
|
- Replaced "Advanced CSV" with a custom CSV syntax definition written especially for `bat`; see #1574 (@keith-hall)
|
||||||
|
- Added SystemVerilog file syntax, see #1580 (@SeanMcLoughlin)
|
||||||
|
- Added Solidity and Vyper syntax, see #1602 (@Ersikan)
|
||||||
|
|
||||||
|
## New themes
|
||||||
|
|
||||||
|
- Dark+ VS Code theme, see #1588 and #1598 (@PatriotRossii)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# v0.18.0
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Use a pager when `bat --list-languages` is called, see #1394 (@stku1985)
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic)
|
||||||
|
- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube)
|
||||||
|
- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
|
||||||
|
- VimL syntax highlighting fix, see #1450 (@esensar)
|
||||||
|
- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic)
|
||||||
|
- If plain mode is set and wrap is not explicitly opted in, long lines will no be truncated, see #1426
|
||||||
|
- If `PAGER` (but not `BAT_PAGER` or `--pager`) is `more` or `most`, silently use `less` instead to ensure support for colors, see #1063 (@Enselic)
|
||||||
|
- If `PAGER` is `bat`, silently use `less` to prevent recursion. For `BAT_PAGER` or `--pager`, exit with error, see #1413 (@Enselic)
|
||||||
|
- Manpage highlighting fix, see #1511 (@keith-hall)
|
||||||
|
- `BAT_CONFIG_PATH` ignored by `bat` if non-existent, see #1550 (@sharkdp)
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
- Performance improvements, see #1421 (@LovecraftianHorror)
|
||||||
|
- Added a new `--diagnostic` option to collect information for bug reports, see #1459 (@sharkdp)
|
||||||
|
- Modified default theme colors to differentiate between a JSON key and a string value, see #1400 (@keith-hall)
|
||||||
|
- Upped min required Rust version to 1.42
|
||||||
|
|
||||||
|
## Syntaxes
|
||||||
|
|
||||||
|
- Added Zig syntax, see #1470 (@paulsmith)
|
||||||
|
- Added Lean syntax, see #1446 (@Julian)
|
||||||
|
- Added `.resource` extension for Robot Framework files, see #1386
|
||||||
|
- Added `gnuplot` syntax, see #1431 (@sharkdp)
|
||||||
|
- Highlight *.pac (Proxy auto-config) files as JavaScript, see #1515 (@sharkdp)
|
||||||
|
|
||||||
|
## New themes
|
||||||
|
|
||||||
|
- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12). **Breaking change:** users that were previously using one of the `ansi-*` themes should switch to `ansi`.
|
||||||
|
- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously using `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead.
|
||||||
|
|
||||||
|
## `bat` as a library
|
||||||
|
|
||||||
|
- The following `PrettyPrinter` methods have been removed (they were previously deprecated):
|
||||||
|
- `input_stdin_with_name`
|
||||||
|
- `input_from_bytes_with_name`
|
||||||
|
- `input_from_reader_with_name`
|
||||||
|
- `vcs_modification_markers` (if the `git` feature is not enabled)
|
||||||
|
|
||||||
|
|
||||||
|
# v0.17.1
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- Running `bat` without arguments fails ("output file is also an input"), see #1396
|
||||||
|
|
||||||
|
|
||||||
|
# v0.17.0
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Added a new `--style` value, `rule`, which adds a simple horizontal ruled line between files, see #1276 (@tommilligan)
|
||||||
|
- Pass `-S` ("chop long lines") to `less` if `--wrap=never` is set in `bat`, see #1255 (@gahag)
|
||||||
|
|
||||||
|
## Bugfixes
|
||||||
|
|
||||||
|
- Detect infinite loop when input and output are the same, see #1193 and #1197 (@niklasmohrin)
|
||||||
|
- Throw an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera)
|
||||||
|
- Bash syntax highlighting not selected for `*.ebuild` and `*.eclass` files, see #1292 (@sharkdp)
|
||||||
|
- Fix `zsh` completion when using `-p`, see #1320 (@xzfc)
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil)
|
||||||
|
- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera)
|
||||||
|
|
||||||
|
## Syntaxes
|
||||||
|
|
||||||
|
- Manpage syntax highlighting has been improved, see #1315 (@keith-hall)
|
||||||
|
- Add Svelte file syntax, see #1285 (@kjmph)
|
||||||
|
|
||||||
|
## New themes
|
||||||
|
|
||||||
|
- Coldark, see #1329 (@armandphilippot)
|
||||||
|
|
||||||
|
|
||||||
# v0.16.0
|
# v0.16.0
|
||||||
|
|
||||||
@@ -420,7 +559,7 @@ You can see the API documentation here: https://docs.rs/bat/
|
|||||||
|
|
||||||
- Added `BAT_CONFIG_PATH` environment variable to set a non-default path for `bat`s configuration file, see #375 (@deg4uss3r)
|
- Added `BAT_CONFIG_PATH` environment variable to set a non-default path for `bat`s configuration file, see #375 (@deg4uss3r)
|
||||||
|
|
||||||
- Allow for multiple occurences of `--style` to allow for the configuration
|
- Allow for multiple occurrences of `--style` to allow for the configuration
|
||||||
of styles from the config file, see #367 (@sindreij)
|
of styles from the config file, see #367 (@sindreij)
|
||||||
|
|
||||||
- Allow for multiple `--line-range` arguments, see #23
|
- Allow for multiple `--line-range` arguments, see #23
|
||||||
|
|||||||
@@ -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 process 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
+642
-592
File diff suppressed because it is too large
Load Diff
+20
-14
@@ -1,17 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
authors = ["David Peter <mail@david-peter.de>"]
|
authors = ["David Peter <mail@david-peter.de>"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
description="A cat(1) clone with wings."
|
description = "A cat(1) clone with wings."
|
||||||
homepage = "https://github.com/sharkdp/bat"
|
homepage = "https://github.com/sharkdp/bat"
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
name = "bat"
|
name = "bat"
|
||||||
readme = "README.md"
|
|
||||||
repository = "https://github.com/sharkdp/bat"
|
repository = "https://github.com/sharkdp/bat"
|
||||||
version = "0.16.0"
|
version = "0.18.2"
|
||||||
exclude = [
|
exclude = ["assets/syntaxes/*", "assets/themes/*"]
|
||||||
"assets/syntaxes/*",
|
|
||||||
"assets/themes/*",
|
|
||||||
]
|
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
edition = '2018'
|
edition = '2018'
|
||||||
|
|
||||||
@@ -22,7 +18,7 @@ default = ["application"]
|
|||||||
application = [
|
application = [
|
||||||
"atty",
|
"atty",
|
||||||
"clap",
|
"clap",
|
||||||
"dirs",
|
"dirs-next",
|
||||||
"git",
|
"git",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"paging",
|
"paging",
|
||||||
@@ -31,6 +27,8 @@ application = [
|
|||||||
]
|
]
|
||||||
git = ["git2"] # Support indicating git modifications
|
git = ["git2"] # Support indicating git modifications
|
||||||
paging = ["shell-words"] # Support applying a pager on the output
|
paging = ["shell-words"] # Support applying a pager on the output
|
||||||
|
|
||||||
|
# You need to use one of these if you depend on bat as a library:
|
||||||
regex-onig = ["syntect/regex-onig"] # Use the "oniguruma" regex engine
|
regex-onig = ["syntect/regex-onig"] # Use the "oniguruma" regex engine
|
||||||
regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
|
regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
|
||||||
|
|
||||||
@@ -38,8 +36,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.14.1"
|
||||||
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 }
|
||||||
content_inspector = "0.2.4"
|
content_inspector = "0.2.4"
|
||||||
@@ -51,6 +48,10 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
semver = "0.11"
|
semver = "0.11"
|
||||||
path_abs = { version = "0.5", default-features = false }
|
path_abs = { version = "0.5", default-features = false }
|
||||||
|
clircle = "0.3"
|
||||||
|
bugreport = "0.4"
|
||||||
|
dirs-next = { version = "2.0.0", optional = true }
|
||||||
|
grep-cli = "0.1.6"
|
||||||
|
|
||||||
[dependencies.git2]
|
[dependencies.git2]
|
||||||
version = "0.13"
|
version = "0.13"
|
||||||
@@ -58,7 +59,7 @@ optional = true
|
|||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.syntect]
|
[dependencies.syntect]
|
||||||
version = "4.4.0"
|
version = "4.5.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["parsing", "yaml-load", "dump-load", "dump-create"]
|
features = ["parsing", "yaml-load", "dump-load", "dump-create"]
|
||||||
|
|
||||||
@@ -73,9 +74,14 @@ version = "0.12"
|
|||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempdir = "0.3"
|
assert_cmd = "1.0.5"
|
||||||
assert_cmd = "1.0.1"
|
serial_test = "0.5.1"
|
||||||
predicates = "1.0.5"
|
predicates = "1.0.7"
|
||||||
|
wait-timeout = "0.2.0"
|
||||||
|
tempfile = "3.2.0"
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dev-dependencies]
|
||||||
|
nix = "0.21.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
clap = { version = "2.33", optional = true }
|
clap = { version = "2.33", optional = true }
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2018-2020 bat-developers (https://github.com/sharkdp/bat).
|
Copyright (c) 2018-2021 bat-developers (https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -94,6 +94,16 @@ bat f - g # output 'f', then stdin, then 'g'.
|
|||||||
|
|
||||||
### Integration with other tools
|
### Integration with other tools
|
||||||
|
|
||||||
|
#### `fzf`
|
||||||
|
|
||||||
|
You can use `bat` as a previewer for [`fzf`](https://github.com/junegunn/fzf). To do this,
|
||||||
|
use `bat`s `--color=always` option to force colorized output. You can also use `--line-range`
|
||||||
|
option to restrict the load times for long files:
|
||||||
|
```bash
|
||||||
|
fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'
|
||||||
|
```
|
||||||
|
For more information, see [`fzf`s `README`](https://github.com/junegunn/fzf#preview-window).
|
||||||
|
|
||||||
#### `find` or `fd`
|
#### `find` or `fd`
|
||||||
|
|
||||||
You can use the `-exec` option of `find` to preview all search results with `bat`:
|
You can use the `-exec` option of `find` to preview all search results with `bat`:
|
||||||
@@ -131,7 +141,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`
|
||||||
|
|
||||||
@@ -152,6 +173,7 @@ bat main.cpp | xclip
|
|||||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||||
man 2 select
|
man 2 select
|
||||||
```
|
```
|
||||||
|
(replace `bat` by `batcat` if you are on Debian or Ubuntu)
|
||||||
|
|
||||||
It might also be necessary to set `MANROFFOPT="-c"` if you experience
|
It might also be necessary to set `MANROFFOPT="-c"` if you experience
|
||||||
formatting problems.
|
formatting problems.
|
||||||
@@ -169,15 +191,15 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
[](https://repology.org/project/bat/versions)
|
[](https://repology.org/project/bat-cat/versions)
|
||||||
|
|
||||||
### On Ubuntu (using `apt`)
|
### On Ubuntu (using `apt`)
|
||||||
*... and other Debian-based Linux distributions.*
|
*... and other Debian-based Linux distributions.*
|
||||||
|
|
||||||
`bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and
|
`bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and
|
||||||
[Debian](https://packages.debian.org/sid/bat) package release process, and is available
|
[Debian](https://packages.debian.org/testing/bat) package release process, and is available
|
||||||
for Ubuntu as of Eoan 19.10. On Debian `bat` is currently only available on the unstable
|
for Ubuntu as of Eoan 19.10. On Debian `bat` is currently available on the unstable
|
||||||
"Sid" branch.
|
"Sid" branch and on the testing branch.
|
||||||
|
|
||||||
If your Ubuntu/Debian installation is new enough you can simply run:
|
If your Ubuntu/Debian installation is new enough you can simply run:
|
||||||
|
|
||||||
@@ -185,7 +207,7 @@ If your Ubuntu/Debian installation is new enough you can simply run:
|
|||||||
apt install bat
|
apt install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
|
**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
|
||||||
clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
|
clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
|
||||||
``` bash
|
``` bash
|
||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
@@ -200,7 +222,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.18.2_amd64.deb # adapt version number and architecture
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Alpine Linux
|
### On Alpine Linux
|
||||||
@@ -245,6 +267,13 @@ You can install `bat` via xbps-install:
|
|||||||
xbps-install -S bat
|
xbps-install -S bat
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### On Termux
|
||||||
|
|
||||||
|
You can install `bat` via pkg:
|
||||||
|
```bash
|
||||||
|
pkg install bat
|
||||||
|
```
|
||||||
|
|
||||||
### On FreeBSD
|
### On FreeBSD
|
||||||
|
|
||||||
You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
|
You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
|
||||||
@@ -276,14 +305,21 @@ You can install `bat` with zypper:
|
|||||||
zypper install bat
|
zypper install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On macOS
|
### Via snap package
|
||||||
|
|
||||||
You can install `bat` with [Homebrew](http://braumeister.org/formula/bat):
|
There is currently no recommended snap package available.
|
||||||
|
Existing packages may be available, but are not officially supported and may contain [issues](https://github.com/sharkdp/bat/issues/1519).
|
||||||
|
|
||||||
|
### On macOS (or Linux) via Homebrew
|
||||||
|
|
||||||
|
You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat):
|
||||||
|
|
||||||
```bash
|
```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
|
||||||
@@ -327,14 +363,14 @@ binaries are also available: look for archives with `musl` in the file name.
|
|||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
If you want to build `bat` from source, you need Rust 1.40 or
|
If you want to build `bat` from source, you need Rust 1.45 or
|
||||||
higher. You can then use `cargo` to build everything:
|
higher. You can then use `cargo` to build everything:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
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
|
||||||
@@ -361,12 +397,11 @@ You can also use a custom theme by following the
|
|||||||
|
|
||||||
### 8-bit themes
|
### 8-bit themes
|
||||||
|
|
||||||
`bat` has four themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
|
`bat` has three themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
|
||||||
even when truecolor support is available:
|
even when truecolor support is available:
|
||||||
|
|
||||||
- `ansi-dark` looks decent on any terminal with a dark background. It uses 3-bit colors: black, red,
|
- `ansi` looks decent on any terminal. It uses 3-bit colors: black, red, green,
|
||||||
green, yellow, blue, magenta, cyan, and white.
|
yellow, blue, magenta, cyan, and white.
|
||||||
- `ansi-light` is like `ansi-dark`, but for terminals with a light background.
|
|
||||||
- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
|
- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
|
||||||
4-bit colors (3-bit colors plus bright variants) in accordance with the
|
4-bit colors (3-bit colors plus bright variants) in accordance with the
|
||||||
[base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
|
[base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
|
||||||
@@ -374,10 +409,11 @@ even when truecolor support is available:
|
|||||||
It replaces certain bright colors with 8-bit colors from 16 to 21. **Do not** use this simply
|
It replaces certain bright colors with 8-bit colors from 16 to 21. **Do not** use this simply
|
||||||
because you have a 256-color terminal but are not using base16-shell.
|
because you have a 256-color terminal but are not using base16-shell.
|
||||||
|
|
||||||
Although these themes are more restricted, they have two advantages over truecolor themes:
|
Although these themes are more restricted, they have three advantages over truecolor themes. They:
|
||||||
|
|
||||||
- They harmonize better with other terminal software using 3-bit or 4-bit colors.
|
- Enjoy maximum compatibility. Some terminal utilities do not support more than 3-bit colors.
|
||||||
- When you change your terminal theme, `bat` output already on the screen will update to match.
|
- Adapt to terminal theme changes. Even for already printed output.
|
||||||
|
- Visually harmonize better with other terminal software.
|
||||||
|
|
||||||
### Output style
|
### Output style
|
||||||
|
|
||||||
@@ -389,35 +425,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 +483,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).
|
||||||
|
|
||||||
|
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
|
||||||
@@ -444,6 +517,8 @@ set, `less` is used by default. If you want to use a different pager, you can ei
|
|||||||
`PAGER` variable or set the `BAT_PAGER` environment variable to override what is specified in
|
`PAGER` variable or set the `BAT_PAGER` environment variable to override what is specified in
|
||||||
`PAGER`.
|
`PAGER`.
|
||||||
|
|
||||||
|
**Note**: If `PAGER` is `more` or `most`, `bat` will silently use `less` instead to ensure support for colors.
|
||||||
|
|
||||||
If you want to pass command-line arguments to the pager, you can also set them via the
|
If you want to pass command-line arguments to the pager, you can also set them via the
|
||||||
`PAGER`/`BAT_PAGER` variables:
|
`PAGER`/`BAT_PAGER` variables:
|
||||||
|
|
||||||
@@ -488,6 +563,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 +600,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 +694,32 @@ 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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to build an application that uses `bat`s pretty-printing
|
||||||
|
features as a library, check out the [the API documentation](https://docs.rs/bat/).
|
||||||
|
Note that you have to use either `regex-onig` or `regex-fancy` as a feature
|
||||||
|
when you depend on `bat` as a library.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
|
||||||
|
|
||||||
## Maintainers
|
## 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)
|
||||||
|
- [Enselic](https://github.com/Enselic)
|
||||||
|
|
||||||
|
## Security vulnerabilities
|
||||||
|
|
||||||
|
Please contact [David Peter](https://david-peter.de/) via email if you want to report a vulnarability in `bat`.
|
||||||
|
|
||||||
## Project goals and alternatives
|
## Project goals and alternatives
|
||||||
|
|
||||||
@@ -646,7 +734,7 @@ There are a lot of alternatives, if you are looking for similar programs. See
|
|||||||
[this document](doc/alternatives.md) for a comparison.
|
[this document](doc/alternatives.md) for a comparison.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Copyright (c) 2018-2020 [bat-developers](https://github.com/sharkdp/bat).
|
Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
`bat` is made available under the terms of either the MIT License or the Apache License 2.0, at your option.
|
`bat` is made available under the terms of either the MIT License or the Apache License 2.0, at your option.
|
||||||
|
|
||||||
|
|||||||
Vendored
-52
@@ -1,52 +0,0 @@
|
|||||||
## Syntax Highlighting in bat
|
|
||||||
|
|
||||||
`bat` uses the [syntect](https://github.com/trishume/syntect) library to highlight source
|
|
||||||
code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions
|
|
||||||
in the `.sublime-syntax` format.
|
|
||||||
|
|
||||||
In order to add new syntaxes to `bat`, follow these steps:
|
|
||||||
|
|
||||||
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`).
|
|
||||||
|
|
||||||
2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in
|
|
||||||
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.
|
|
||||||
|
|
||||||
3. Run the `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).
|
|
||||||
|
|
||||||
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
|
|
||||||
`bat` binary.
|
|
||||||
|
|
||||||
5. 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`.
|
|
||||||
|
|
||||||
### Troubleshooting
|
|
||||||
|
|
||||||
Make sure that the local cache does not interfere with the internally stored syntaxes and
|
|
||||||
themes (`bat cache --clear`).
|
|
||||||
|
|
||||||
### Manual modifications
|
|
||||||
|
|
||||||
The following files have been manually modified after converting from a `.tmLanguage` file:
|
|
||||||
|
|
||||||
* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
|
|
||||||
* `Dart.sublime-syntax` => removed `#regex.dart` include.
|
|
||||||
* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
|
|
||||||
* `Org mode.sublime-syntax` => removed `task` file type.
|
|
||||||
* `SML.sublime_syntax` => removed `ml` file type.
|
|
||||||
|
|
||||||
### Non-submodule additions
|
|
||||||
|
|
||||||
* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems
|
|
||||||
* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime
|
|
||||||
* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax
|
|
||||||
as it is not kept in a standalone repository. The file is generated from
|
|
||||||
https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage
|
|
||||||
* `SML.sublime_syntax` has been added manually from
|
|
||||||
https://github.com/seanjames777/SML-Language-Definitiona as it is not
|
|
||||||
kept in a standalone repository. The file generated is from
|
|
||||||
https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
|
|
||||||
* `Cabal.sublime_syntax` has been added manually from
|
|
||||||
https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
|
|
||||||
Vendored
+88
@@ -0,0 +1,88 @@
|
|||||||
|
# shellcheck disable=SC2207
|
||||||
|
|
||||||
|
# Requires https://github.com/scop/bash-completion
|
||||||
|
|
||||||
|
_bat() {
|
||||||
|
local cur prev words cword split
|
||||||
|
_init_completion -s || return 0
|
||||||
|
|
||||||
|
if [[ ${words[1]-} == cache ]]; then
|
||||||
|
case $prev in
|
||||||
|
--source | --target)
|
||||||
|
_filedir -d
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
COMPREPLY=($(compgen -W "
|
||||||
|
--build --clear --source --target --blank --help
|
||||||
|
" -- "$cur"))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $prev in
|
||||||
|
-l | --language)
|
||||||
|
local IFS=$'\n'
|
||||||
|
COMPREPLY=($(compgen -W "$(
|
||||||
|
"$1" --list-languages | while IFS=: read -r lang _; do
|
||||||
|
printf "%s\n" "$lang"
|
||||||
|
done
|
||||||
|
)" -- "$cur"))
|
||||||
|
compopt -o filenames # for escaping
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
-H | --highlight-line | --diff-context | --tabs | --terminal-width | \
|
||||||
|
-m | --map-syntax | --style | --line-range | -h | --help | -V | \
|
||||||
|
--version | --diagnostic | --config-file | --config-dir | \
|
||||||
|
--cache-dir | --generate-config-file)
|
||||||
|
# argument required but no completion available, or option
|
||||||
|
# causes an exit
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--file-name)
|
||||||
|
_filedir
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--wrap)
|
||||||
|
COMPREPLY=($(compgen -W "auto never character" -- "$cur"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--color | --decorations | --paging)
|
||||||
|
COMPREPLY=($(compgen -W "auto never always" -- "$cur"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--italic-text)
|
||||||
|
COMPREPLY=($(compgen -W "always never" -- "$cur"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--pager)
|
||||||
|
COMPREPLY=($(compgen -c -- "$cur"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--theme)
|
||||||
|
local IFS=$'\n'
|
||||||
|
COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur"))
|
||||||
|
compopt -o filenames # for escaping
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return 0
|
||||||
|
|
||||||
|
if [[ $cur == -* ]]; then
|
||||||
|
COMPREPLY=($(compgen -W "
|
||||||
|
--show-all --plain --language --highlight-line
|
||||||
|
--file-name --diff --diff-context --tabs --wrap
|
||||||
|
--terminal-width --number --color --italic-text
|
||||||
|
--decorations --paging --pager --map-syntax --theme
|
||||||
|
--list-themes --style --line-range --list-languages
|
||||||
|
--help --version --force-colorization --unbuffered
|
||||||
|
--diagnostic --config-file --config-dir --cache-dir
|
||||||
|
--generate-config-file
|
||||||
|
" -- "$cur"))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
_filedir
|
||||||
|
((cword == 1)) && COMPREPLY+=($(compgen -W cache -- "$cur"))
|
||||||
|
|
||||||
|
} && complete -F _bat {{PROJECT_EXECUTABLE}}
|
||||||
Vendored
+15
-10
@@ -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'
|
||||||
@@ -44,6 +44,11 @@ _main() {
|
|||||||
'(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style'
|
'(--style)'--style='[Comma-separated list of style elements to display]:<components>:->style'
|
||||||
'(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N\:M>...'
|
'(-r --line-range)'{-r+,--line-range=}'[Only print the lines from N to M]:<N\:M>...'
|
||||||
'(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]'
|
'(: --list-themes --list-languages -L)'{-L,--list-languages}'[Display all supported languages]'
|
||||||
|
'(: --no-config)'--no-config'[Do not use the configuration file]'
|
||||||
|
'(: --config-dir)'--config-dir'[Show bat'"'"'s configuration directory]'
|
||||||
|
'(: --config-file)'--config-file'[Show path to the configuration file]'
|
||||||
|
'(: --generate-config-file)'--generate-config-file'[Generates a default configuration file]'
|
||||||
|
'(: --cache-dir)'--cache-dir'[Show bat'"'"'s cache directory]'
|
||||||
'(: -)'{-h,--help}'[Print this help message]'
|
'(: -)'{-h,--help}'[Print this help message]'
|
||||||
'(: -)'{-V,--version}'[Show version information]'
|
'(: -)'{-V,--version}'[Show version information]'
|
||||||
'*: :_files'
|
'*: :_files'
|
||||||
@@ -51,13 +56,13 @@ _main() {
|
|||||||
|
|
||||||
_arguments -S -s $args
|
_arguments -S -s $args
|
||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
language)
|
language)
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local -a languages
|
local -a languages
|
||||||
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
||||||
|
|
||||||
_describe 'language' languages
|
_describe 'language' languages
|
||||||
;;
|
;;
|
||||||
|
|
||||||
theme)
|
theme)
|
||||||
@@ -79,15 +84,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
|
||||||
|
|||||||
Vendored
+1
-1
@@ -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 )"
|
||||||
|
|||||||
Vendored
+25
-8
@@ -40,7 +40,7 @@ language names and file extensions.
|
|||||||
.HP
|
.HP
|
||||||
\fB\-H\fR, \fB\-\-highlight\-line\fR <N:M>...
|
\fB\-H\fR, \fB\-\-highlight\-line\fR <N:M>...
|
||||||
.IP
|
.IP
|
||||||
Highlight the specified line ranges with a different background color For example:
|
Highlight the specified line ranges with a different background color. For example:
|
||||||
.RS
|
.RS
|
||||||
.IP "\-\-highlight\-line 40"
|
.IP "\-\-highlight\-line 40"
|
||||||
highlights line 40
|
highlights line 40
|
||||||
@@ -52,6 +52,18 @@ highlights lines 1 to 40
|
|||||||
highlights lines 40 to the end of the file
|
highlights lines 40 to the end of the file
|
||||||
.RE
|
.RE
|
||||||
.HP
|
.HP
|
||||||
|
\fB\-\-file\-name\fR <name>...
|
||||||
|
.IP
|
||||||
|
Specify the name to display for a file. Useful when piping data to {{PROJECT_EXECUTABLE}} from STDIN when {{PROJECT_EXECUTABLE}} does not otherwise know the filename. Note that the provided file name is also used for syntax detection.
|
||||||
|
.HP
|
||||||
|
\fB\-d\fR, \fB\-\-diff\fR
|
||||||
|
.IP
|
||||||
|
Only show lines that have been added/removed/modified with respect to the Git index. Use '\-\-diff\-context=N' to control how much context you want to see.
|
||||||
|
.HP
|
||||||
|
\fB\-\-diff\-context\fR <N>...
|
||||||
|
.IP
|
||||||
|
Include N lines of context around added/removed/modified lines when using '\-\-diff'.
|
||||||
|
.HP
|
||||||
\fB\-\-tabs\fR <T>
|
\fB\-\-tabs\fR <T>
|
||||||
.IP
|
.IP
|
||||||
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly
|
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly
|
||||||
@@ -90,7 +102,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>
|
||||||
@@ -111,6 +123,7 @@ Map a glob pattern to an existing syntax name. The glob pattern is matched on th
|
|||||||
path and the filename. For example, to highlight *.build files with the Python syntax,
|
path and the filename. For example, to highlight *.build files with the Python syntax,
|
||||||
use -m '*.build:Python'. To highlight files named '.myignore' with the Git Ignore
|
use -m '*.build:Python'. To highlight files named '.myignore' with the Git Ignore
|
||||||
syntax, use -m '.myignore:Git Ignore'.
|
syntax, use -m '.myignore:Git Ignore'.
|
||||||
|
Note that the right-hand side is the *name* of the syntax, not a file extension.
|
||||||
.HP
|
.HP
|
||||||
\fB\-\-theme\fR <theme>
|
\fB\-\-theme\fR <theme>
|
||||||
.IP
|
.IP
|
||||||
@@ -129,7 +142,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 +187,16 @@ 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.
|
||||||
|
|
||||||
|
To generate a default configuration file, call:
|
||||||
|
|
||||||
|
\fB{{PROJECT_EXECUTABLE}} --generate-config-file\fR
|
||||||
.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 +216,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.
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
diff --git themes/sublime-monokai-extended/Monokai\ Extended.tmTheme themes/sublime-monokai-extended/Monokai\ Extended.tmTheme
|
||||||
|
index 9c2aa3e..180cbbf 100644
|
||||||
|
--- themes/sublime-monokai-extended/Monokai Extended.tmTheme
|
||||||
|
+++ themes/sublime-monokai-extended/Monokai Extended.tmTheme
|
||||||
|
@@ -810,11 +810,11 @@
|
||||||
|
<key>name</key>
|
||||||
|
<string>JSON String</string>
|
||||||
|
<key>scope</key>
|
||||||
|
- <string>meta.structure.dictionary.json string.quoted.double.json</string>
|
||||||
|
+ <string>meta.mapping.key.json string.quoted.double.json, punctuation.separator.sequence.csv</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>foreground</key>
|
||||||
|
- <string>#cfcfc2</string>
|
||||||
|
+ <string>#fd971f</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
@@ -1027,7 +1027,7 @@
|
||||||
|
<key>name</key>
|
||||||
|
<string>Invalid</string>
|
||||||
|
<key>scope</key>
|
||||||
|
- <string>invalid</string>
|
||||||
|
+ <string>invalid, markup.error</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
|
@@ -1042,7 +1042,7 @@
|
||||||
|
<key>name</key>
|
||||||
|
<string>Invalid deprecated</string>
|
||||||
|
<key>scope</key>
|
||||||
|
- <string>invalid.deprecated</string>
|
||||||
|
+ <string>invalid.deprecated, markup.warning</string>
|
||||||
|
<key>settings</key>
|
||||||
|
<dict>
|
||||||
|
<key>background</key>
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
diff --git syntaxes/01_Packages/ShellScript/Bash.sublime-syntax syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
|
||||||
|
index e973e319..07c170a7 100644
|
||||||
|
--- syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
|
||||||
|
+++ syntaxes/01_Packages/ShellScript/Bash.sublime-syntax
|
||||||
|
@@ -30,12 +30,12 @@ file_extensions:
|
||||||
|
- .zshenv
|
||||||
|
- .zshrc
|
||||||
|
- PKGBUILD # https://jlk.fjfi.cvut.cz/arch/manpages/man/PKGBUILD.5
|
||||||
|
- - .ebuild
|
||||||
|
- - .eclass
|
||||||
|
+ - ebuild
|
||||||
|
+ - eclass
|
||||||
|
|
||||||
|
first_line_match: |
|
||||||
|
(?x)
|
||||||
|
- ^\#! .* \b(bash|zsh|sh|tcsh|ash)\b
|
||||||
|
+ ^\#! .* \b(bash|zsh|sh|tcsh|ash|dash)\b
|
||||||
|
| ^\# \s* -\*- [^*]* mode: \s* shell-script [^*]* -\*-
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
diff --git syntaxes/01_Packages/XML/XML.sublime-syntax syntaxes/01_Packages/XML/XML.sublime-syntax
|
||||||
|
index ad7d9c87..af4a00f0 100644
|
||||||
|
--- syntaxes/01_Packages/XML/XML.sublime-syntax
|
||||||
|
+++ syntaxes/01_Packages/XML/XML.sublime-syntax
|
||||||
|
@@ -12,6 +12,7 @@ file_extensions:
|
||||||
|
- rss
|
||||||
|
- opml
|
||||||
|
- svg
|
||||||
|
+ - xaml
|
||||||
|
first_line_match: |-
|
||||||
|
(?x:
|
||||||
|
^(?:
|
||||||
Vendored
BIN
Binary file not shown.
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/AWK updated: e593eb6d42...e23926eca1
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/CMake updated: aba96a0862...ab6ef4ef9f
Vendored
-1
Submodule assets/syntaxes/02_Extra/CSV deleted from 4786d037a7
+71
-39
@@ -1,46 +1,78 @@
|
|||||||
%YAML 1.2
|
%YAML 1.2
|
||||||
---
|
---
|
||||||
# http://www.sublimetext.com/docs/3/syntax.html
|
# See http://www.sublimetext.com/docs/3/syntax.html
|
||||||
name: Advanced CSV
|
name: Comma Separated Values
|
||||||
file_extensions:
|
file_extensions:
|
||||||
- csv
|
- csv
|
||||||
- tsv
|
- tsv
|
||||||
scope: text.advanced_csv
|
scope: text.csv
|
||||||
|
variables:
|
||||||
|
field_separator: (?:[,;\t])
|
||||||
|
record_separator: (?:$\n?)
|
||||||
contexts:
|
contexts:
|
||||||
|
prototype:
|
||||||
|
- match: (?={{record_separator}})
|
||||||
|
pop: true
|
||||||
|
fields:
|
||||||
|
- match: ''
|
||||||
|
push:
|
||||||
|
- field_or_record_separator
|
||||||
|
- field4
|
||||||
|
- field_or_record_separator
|
||||||
|
- field3
|
||||||
|
- field_or_record_separator
|
||||||
|
- field2
|
||||||
|
- field_or_record_separator
|
||||||
|
- field1
|
||||||
main:
|
main:
|
||||||
- match: (\")
|
- meta_include_prototype: false
|
||||||
captures:
|
- match: '^'
|
||||||
1: string.quoted.double.advanced_csv
|
set: fields
|
||||||
push:
|
|
||||||
- meta_scope: meta.quoted.advanced_csv
|
field_or_record_separator:
|
||||||
- match: (\")
|
- meta_include_prototype: false
|
||||||
captures:
|
- match: '{{record_separator}}'
|
||||||
1: string.quoted.double.advanced_csv
|
scope: punctuation.terminator.record.csv
|
||||||
pop: true
|
pop: true
|
||||||
- include: main
|
- match: '{{field_separator}}'
|
||||||
- match: '(\[([+-]?\d*)(\:)?([+-]?\d*)(\,)?([+-]?\d*)(\:)?([+-]?\d*)\])?\s*([<>v^])?\s*(=)'
|
scope: punctuation.separator.sequence.csv
|
||||||
captures:
|
pop: true
|
||||||
1: keyword.operator.advanced_csv
|
|
||||||
2: constant.numeric.formula.advanced_csv
|
field_contents:
|
||||||
4: constant.numeric.formula.advanced_csv
|
- match: '"'
|
||||||
6: constant.numeric.formula.advanced_csv
|
scope: punctuation.definition.string.begin.csv
|
||||||
8: constant.numeric.formula.advanced_csv
|
push: double_quoted_string
|
||||||
9: keyword.operator.advanced_csv
|
|
||||||
10: keyword.operator.advanced_csv
|
- match: (?={{field_separator}}|{{record_separator}})
|
||||||
push:
|
pop: true
|
||||||
- meta_scope: meta.range.advanced_csv
|
|
||||||
- match: (?=(\")|$)
|
double_quoted_string:
|
||||||
pop: true
|
- meta_include_prototype: false
|
||||||
- include: scope:source.python
|
- meta_scope: string.quoted.double.csv
|
||||||
- match: '(?<=^|,|\s|\")([0-9.eE+-]+)(?=$|,|\s|\")'
|
- match: '""'
|
||||||
scope: meta.number.advanced_csv
|
scope: constant.character.escape.csv
|
||||||
captures:
|
- match: '"'
|
||||||
1: constant.numeric.advanced_csv
|
scope: punctuation.definition.string.end.csv
|
||||||
- match: '(?<=^|,|\s|\")([^, \t\"]+)(?=$|,|\s|\")'
|
pop: true
|
||||||
scope: meta.nonnumber.advanced_csv
|
|
||||||
captures:
|
field1:
|
||||||
1: storage.type.advanced_csv
|
- match: ''
|
||||||
- match: (\,)
|
set:
|
||||||
scope: meta.delimiter.advanced_csv
|
- meta_content_scope: meta.field-1.csv support.type
|
||||||
captures:
|
- include: field_contents
|
||||||
1: keyword.operator.advanced_csv
|
field2:
|
||||||
|
- match: ''
|
||||||
|
set:
|
||||||
|
- meta_content_scope: meta.field-2.csv support.function
|
||||||
|
- include: field_contents
|
||||||
|
field3:
|
||||||
|
- match: ''
|
||||||
|
set:
|
||||||
|
- meta_content_scope: meta.field-3.csv constant.numeric
|
||||||
|
- include: field_contents
|
||||||
|
field4:
|
||||||
|
- match: ''
|
||||||
|
set:
|
||||||
|
- meta_content_scope: meta.field-4.csv keyword.operator
|
||||||
|
- include: field_contents
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Crystal updated: 5e032ff5f5...eb63666f35
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/DotENV updated: a1c917633d...58201ba2ab
+4
-2
@@ -4,7 +4,6 @@
|
|||||||
name: DotENV
|
name: DotENV
|
||||||
file_extensions:
|
file_extensions:
|
||||||
- .env
|
- .env
|
||||||
- .envrc
|
|
||||||
- .env.dist
|
- .env.dist
|
||||||
- .env.local
|
- .env.local
|
||||||
- .env.sample
|
- .env.sample
|
||||||
@@ -19,8 +18,11 @@ file_extensions:
|
|||||||
- .env.production
|
- .env.production
|
||||||
- .env.production.local
|
- .env.production.local
|
||||||
- .env.dusk.local
|
- .env.dusk.local
|
||||||
- .flaskenv
|
|
||||||
- .env.staging
|
- .env.staging
|
||||||
|
- .env.default
|
||||||
|
- .env.defaults
|
||||||
|
- .envrc
|
||||||
|
- .flaskenv
|
||||||
scope: source.env
|
scope: source.env
|
||||||
contexts:
|
contexts:
|
||||||
main:
|
main:
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Elixir updated: 4ee539b43d...4fb01891dd
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/FSharp updated: c18616d6bd...9e4645c608
@@ -5,6 +5,7 @@ name: fstab
|
|||||||
file_extensions:
|
file_extensions:
|
||||||
- fstab
|
- fstab
|
||||||
- crypttab
|
- crypttab
|
||||||
|
- mtab
|
||||||
scope: source.fstab
|
scope: source.fstab
|
||||||
|
|
||||||
contexts:
|
contexts:
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/GraphQL updated: c9d84587eb...59304d6c7b
+2
-1
@@ -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:
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Julia updated: 6c0d770fc7...48639e1dbf
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/LESS updated: 44632e19af...a2eae0453e
+1
Submodule assets/syntaxes/02_Extra/Lean added at 29a03a8aba
+125
@@ -0,0 +1,125 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: Lean
|
||||||
|
file_extensions:
|
||||||
|
- lean
|
||||||
|
scope: source.lean
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- include: comments
|
||||||
|
- match: '\b(?<!\.)(inductive|coinductive|structure|theorem|axiom|axioms|abbreviation|lemma|definition|def|instance|class|constant)\b\s+(\{[^}]*\})?'
|
||||||
|
captures:
|
||||||
|
1: keyword.other.definitioncommand.lean
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.definitioncommand.lean
|
||||||
|
- match: '(?=\bwith\b|\bextends\b|[:\|\(\[\{⦃<>])'
|
||||||
|
pop: true
|
||||||
|
- include: comments
|
||||||
|
- include: definitionName
|
||||||
|
- match: ","
|
||||||
|
- match: \b(Prop|Type|Sort)\b
|
||||||
|
scope: storage.type.lean
|
||||||
|
- match: '\battribute\b\s*\[[^\]]*\]'
|
||||||
|
scope: storage.modifier.lean
|
||||||
|
- match: '@\[[^\]]*\]'
|
||||||
|
scope: storage.modifier.lean
|
||||||
|
- match: \b(?<!\.)(private|meta|mutual|protected|noncomputable)\b
|
||||||
|
scope: keyword.control.definition.modifier.lean
|
||||||
|
- match: \b(sorry)\b
|
||||||
|
scope: invalid.illegal.lean
|
||||||
|
- match: '#print\s+(def|definition|inductive|instance|structure|axiom|axioms|class)\b'
|
||||||
|
scope: keyword.other.command.lean
|
||||||
|
- match: '#(print|eval|reduce|check|help|exit|find|where)\b'
|
||||||
|
scope: keyword.other.command.lean
|
||||||
|
- match: \b(?<!\.)(import|export|prelude|theory|definition|def|abbreviation|instance|renaming|hiding|exposing|parameter|parameters|begin|constant|constants|lemma|variable|variables|theorem|example|open|axiom|inductive|coinductive|with|structure|universe|universes|alias|precedence|reserve|postfix|prefix|infix|infixl|infixr|notation|end|using|namespace|section|local|set_option|extends|include|omit|class|classes|instances|raw|run_cmd|restate_axiom)(?!\.)\b
|
||||||
|
scope: keyword.other.lean
|
||||||
|
- match: \b(?<!\.)(calc|have|this|match|do|suffices|show|by|in|at|let|forall|fun|exists|assume|from|obtain|haveI|λ)(?!\.)\b
|
||||||
|
scope: keyword.other.lean
|
||||||
|
- match: «
|
||||||
|
push:
|
||||||
|
- meta_content_scope: entity.name.lean
|
||||||
|
- match: »
|
||||||
|
pop: true
|
||||||
|
- match: \b(?<!\.)(if|then|else)\b
|
||||||
|
scope: keyword.control.lean
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.begin.lean
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.lean
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.end.lean
|
||||||
|
pop: true
|
||||||
|
- match: '\\[\\"nt'']'
|
||||||
|
scope: constant.character.escape.lean
|
||||||
|
- match: '\\x[0-9A-Fa-f][0-9A-Fa-f]'
|
||||||
|
scope: constant.character.escape.lean
|
||||||
|
- match: '\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'
|
||||||
|
scope: constant.character.escape.lean
|
||||||
|
- match: '''[^\\'']'''
|
||||||
|
scope: string.quoted.single.lean
|
||||||
|
- match: '''(\\(x..|u....|.))'''
|
||||||
|
scope: string.quoted.single.lean
|
||||||
|
captures:
|
||||||
|
1: constant.character.escape.lean
|
||||||
|
- match: '`+[^\[(]\S+'
|
||||||
|
scope: entity.name.lean
|
||||||
|
- match: '\b([0-9]+|0([xX][0-9a-fA-F]+))\b'
|
||||||
|
scope: constant.numeric.lean
|
||||||
|
blockComment:
|
||||||
|
- match: /-
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.lean
|
||||||
|
- match: "-/"
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lean.markdown
|
||||||
|
- include: blockComment
|
||||||
|
comments:
|
||||||
|
- include: dashComment
|
||||||
|
- include: docComment
|
||||||
|
- include: stringBlock
|
||||||
|
- include: modDocComment
|
||||||
|
- include: blockComment
|
||||||
|
dashComment:
|
||||||
|
- match: (--)
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.comment.lean
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.line.double-dash.lean
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lean.markdown
|
||||||
|
definitionName:
|
||||||
|
- match: '\b[^:«»\(\)\{\}[:space:]=→λ∀?][^:«»\(\)\{\}[:space:]]*'
|
||||||
|
scope: entity.name.function.lean
|
||||||
|
- match: «
|
||||||
|
push:
|
||||||
|
- meta_content_scope: entity.name.function.lean
|
||||||
|
- match: »
|
||||||
|
pop: true
|
||||||
|
docComment:
|
||||||
|
- match: /--
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.documentation.lean
|
||||||
|
- match: "-/"
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lean.markdown
|
||||||
|
- include: blockComment
|
||||||
|
modDocComment:
|
||||||
|
- match: /-!
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.documentation.lean
|
||||||
|
- match: "-/"
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lean.markdown
|
||||||
|
- include: blockComment
|
||||||
|
stringBlock:
|
||||||
|
- match: /-"
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.string.lean
|
||||||
|
- match: '"-/'
|
||||||
|
pop: true
|
||||||
|
- include: scope:source.lean.markdown
|
||||||
|
- include: blockComment
|
||||||
+147
-29
@@ -7,47 +7,165 @@ 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
|
||||||
|
|
||||||
- match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
|
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_\-]+\.)?([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
|
||||||
captures:
|
captures:
|
||||||
1: entity.name.function
|
1: entity.name.function.man
|
||||||
2: keyword.operator
|
2: entity.name.function.man
|
||||||
3: constant.numeric
|
3: keyword.operator.man
|
||||||
4: keyword.operator
|
4: constant.numeric.man
|
||||||
|
5: keyword.operator.man
|
||||||
|
|
||||||
|
env-var:
|
||||||
|
- match: '(\$)(?!\d)(\w+)\b'
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.variable.man
|
||||||
|
2: constant.other.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
|
||||||
|
- include: env-var
|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
+1
Submodule assets/syntaxes/02_Extra/Ninja added at 25830aaec9
+52
@@ -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
|
||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
%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
|
||||||
|
- resource
|
||||||
scope: source.robot
|
scope: source.robot
|
||||||
contexts:
|
contexts:
|
||||||
main:
|
main:
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/SCSS_Sass updated: bc6332c1be...63819a1ab6
+1
Submodule assets/syntaxes/02_Extra/SublimeEthereum added at b60e0a3e00
+1
Submodule assets/syntaxes/02_Extra/Svelte added at c71f1290b0
Vendored
-1
Submodule assets/syntaxes/02_Extra/Syslog deleted from 7628d4e0b8
+1
Submodule assets/syntaxes/02_Extra/SystemVerilog added at 7eca705e87
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/Terraform updated: 64208ea816...54d8350c3c
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/TypeScript updated: f21aba57c5...a607ddfec9
@@ -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:
|
||||||
|
|||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/VimL updated: ed40c3bc81...7ebcaa1d98
-91
@@ -1,91 +0,0 @@
|
|||||||
%YAML 1.2
|
|
||||||
---
|
|
||||||
# http://www.sublimetext.com/docs/3/syntax.html
|
|
||||||
name: VimL
|
|
||||||
file_extensions:
|
|
||||||
- vim
|
|
||||||
- .vimrc
|
|
||||||
scope: source.viml
|
|
||||||
contexts:
|
|
||||||
main:
|
|
||||||
- include: comment
|
|
||||||
- include: string_quoted_double
|
|
||||||
- include: string_quoted_single
|
|
||||||
- include: string_regex
|
|
||||||
- include: inline_comment
|
|
||||||
- include: number_int
|
|
||||||
- include: number_hex
|
|
||||||
- include: keyword
|
|
||||||
- include: support_function
|
|
||||||
- include: support_variable
|
|
||||||
- include: support_type
|
|
||||||
- include: function_params
|
|
||||||
- include: function_definition
|
|
||||||
- include: function_call
|
|
||||||
- include: function
|
|
||||||
- include: variable
|
|
||||||
- include: expr
|
|
||||||
comment:
|
|
||||||
- match: ^\s*".*$
|
|
||||||
scope: comment.line.quotes.viml
|
|
||||||
captures:
|
|
||||||
1: punctuation.definition.comment.vim
|
|
||||||
expr:
|
|
||||||
- match: (\|\||&&|==(\?|#)?|(!|>|<)=(#|\?)?|(=|!)~(#|\?)?|(>|<)(#|\?)is|isnot|\.|\*|\\|%)
|
|
||||||
scope: storage.function.viml
|
|
||||||
function:
|
|
||||||
- match: \b(fu(n|nction)?|end(f|fu|fun|function)?)\b
|
|
||||||
scope: storage.function.viml
|
|
||||||
function_call:
|
|
||||||
- match: '(([sgbwtl]|)?:?[0-9a-zA-Z_#]+)(?=\()'
|
|
||||||
scope: support.function.any-method
|
|
||||||
function_definition:
|
|
||||||
- match: '^\s*(function)\s*!?\s+(?=(s:)?[0-9a-zA-Z_#]+\s*\()'
|
|
||||||
captures:
|
|
||||||
1: storage.function.viml
|
|
||||||
push:
|
|
||||||
- meta_scope: meta.function.viml
|
|
||||||
- match: (\()
|
|
||||||
captures:
|
|
||||||
1: punctuation.definition.parameters.begin.viml
|
|
||||||
pop: true
|
|
||||||
- match: "(s:)?[0-9a-zA-Z_#]+"
|
|
||||||
scope: entity.name.function.viml
|
|
||||||
function_params:
|
|
||||||
- match: '-\w+='
|
|
||||||
scope: support.type.viml
|
|
||||||
inline_comment:
|
|
||||||
- match: '(?!\$)(")(?!\{).*$\n?'
|
|
||||||
scope: comment.line.quotes.viml
|
|
||||||
captures:
|
|
||||||
1: punctuation.definition.comment.vim
|
|
||||||
keyword:
|
|
||||||
- match: \b(if|while|for|try|return|throw|end(if|for|while|try)?|au(g|group)|else(if|)?|do|in|catch|finally|:)\b
|
|
||||||
scope: keyword.control.viml
|
|
||||||
number_hex:
|
|
||||||
- match: "0x[0-9a-f]+"
|
|
||||||
scope: constant.numeric.hex
|
|
||||||
number_int:
|
|
||||||
- match: '-?\d+'
|
|
||||||
scope: constant.numeric.integer
|
|
||||||
string_quoted_double:
|
|
||||||
- match: '"(\\\\|\\"|\n[^\S\n]*\\|[^\n"])*"'
|
|
||||||
scope: string.quoted.double.viml
|
|
||||||
string_quoted_single:
|
|
||||||
- match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
|
|
||||||
scope: string.quoted.single.viml
|
|
||||||
string_regex:
|
|
||||||
- match: '/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
|
|
||||||
scope: string.regexp.viml
|
|
||||||
support_function:
|
|
||||||
- match: \b(set(local|global)?|let|command|filetype|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
|
|
||||||
scope: support.function.viml
|
|
||||||
support_type:
|
|
||||||
- match: <.*?>
|
|
||||||
scope: support.type.viml
|
|
||||||
support_variable:
|
|
||||||
- match: '\b(am(enu|)?|(hl|inc)?search|[Bb]uf([Nn]ew[Ff]ile|[Rr]ead)?|[Ff]ile[Tt]ype)\b'
|
|
||||||
scope: support.variable.viml
|
|
||||||
variable:
|
|
||||||
- match: '([sSgGbBwWlLaAvV]:|@|$|&(?!&))\w*'
|
|
||||||
scope: variable.other.viml
|
|
||||||
+1
Submodule assets/syntaxes/02_Extra/Zig added at 87ecbcae6f
+1
Submodule assets/syntaxes/02_Extra/gnuplot added at 04743470ff
+182
@@ -0,0 +1,182 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: gnuplot
|
||||||
|
file_extensions:
|
||||||
|
- gp
|
||||||
|
- gpl
|
||||||
|
- gnuplot
|
||||||
|
- gnu
|
||||||
|
- plot
|
||||||
|
- plt
|
||||||
|
scope: source.gnuplot
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- include: number
|
||||||
|
- include: string_single
|
||||||
|
- include: string_double
|
||||||
|
- match: '\b(for)\b\s*(\[)'
|
||||||
|
comment: |
|
||||||
|
gnuplot iteration statement.
|
||||||
|
There are two forms:
|
||||||
|
numeric [n = 1:2{:inc}]
|
||||||
|
string based [str in "x y z"]
|
||||||
|
but both can also iterate over lists etc, so this is kept loose.
|
||||||
|
captures:
|
||||||
|
1: keyword.other.iteration.gnuplot
|
||||||
|
2: punctuation.definition.range.begin.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.structure.iteration.gnuplot
|
||||||
|
- match: '\]'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.range.end.gnuplot
|
||||||
|
pop: true
|
||||||
|
- include: number
|
||||||
|
- include: operator
|
||||||
|
- include: string_double
|
||||||
|
- include: string_single
|
||||||
|
- match: ":"
|
||||||
|
scope: punctuation.separator.range.gnuplot
|
||||||
|
- match: '\b([a-zA-Z]\w*)\b\s*(=|in)'
|
||||||
|
scope: variable-assignment.range.gnuplot
|
||||||
|
- match: '(?i:[^\s(pi|e)\]])'
|
||||||
|
scope: invalid.illegal.expected-range-separator.gnuplot
|
||||||
|
- match: '\['
|
||||||
|
comment: "gnuplot range statement [a:b]. Lots of things are legal, still more make no sense!"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.range.begin.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.structure.range.gnuplot
|
||||||
|
- match: '\]'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.range.end.gnuplot
|
||||||
|
pop: true
|
||||||
|
- include: number
|
||||||
|
- include: operator
|
||||||
|
- match: ":"
|
||||||
|
scope: punctuation.separator.range.gnuplot
|
||||||
|
- match: '(?i:[^\s(pi|e)\]])'
|
||||||
|
scope: invalid.illegal.expected-range-separator.gnuplot
|
||||||
|
- match: \\.
|
||||||
|
scope: constant.character.escape.gnuplot
|
||||||
|
- match: '(?<!\$)(#)(?!\{).*$\n?'
|
||||||
|
scope: comment.line.number-sign.gnuplot
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.comment.gnuplot
|
||||||
|
- match: for
|
||||||
|
comment: introduce in gnuplot 4.3.
|
||||||
|
scope: keyword.other.iteration.gnuplot
|
||||||
|
- match: \b(angles|arrow|autoscale|bars|border|boxwidth|clabel|clip|cntrparam|colorbox|contour|decimalsign|dgrid3d|dummy|encoding|fit|format|grid|hidden3d|historysize|isosamples|key|label|locale|logscale|macros|bmargin|lmargin|rmargin|tmargin|mapping|mouse|multiplot|offsets|origin|output|palette|parametric|pm3d|pointsize|polar|print|rrange|trange|urange|vrange|samples|size|style|surface|tics|ticscale|ticslevel|timestamp|timefmt|title|view|xyplane|x2data|xdata|y2data|ydata|z2data|zdata|x2label|xlabel|y2label|ylabel|z2label|zlabel|x2range|xrange|y2range|yrange|z2range|zrange|mx2tics|mxtics|my2tics|mytics|mz2tics|mztics|nomx2tics|nomxtics|nomy2tics|nomytics|nomz2tics|nomztics|nox2tics|noxtics|noy2tics|noytics|noz2tics|noztics|x2tics|xtics|y2tics|ytics|z2tics|ztics|x2dtics|x2mtics|xdtics|xmtics|y2dtics|y2mtics|ydtics|ymtics|z2dtics|z2mtics|zdtics|zmtics|x2zeroaxis|xzeroaxis|y2zeroaxis|yzeroaxis|z2zeroaxis|zeroaxis|zzeroaxis|zero|)\b
|
||||||
|
scope: keyword.other.setting.gnuplot
|
||||||
|
- match: \b(cd|call|clear|exit|plot|splot|help|load|pause|quit|fit|replot|if|FIT_LIMIT|FIT_MAXITER|FIT_START_LAMBDA|FIT_LAMBDA_FACTOR|FIT_LOG|FIT_SCRIPT|print|pwd|reread|reset|save|show|test|!|functions|var)\b
|
||||||
|
comment: missuse of scopes alert! Just for pretty colours
|
||||||
|
scope: keyword.other.command.gnuplot
|
||||||
|
- match: \b(abs|acos|acosh|arg|asin|asinh|atan|atan2|atanh|besj0|besj1|besy0|besy1|ceil|cos|cosh|erf|erfc|exp|floor|gamma|ibeta|igamma|imag|int|inverf|invnorm|lambertw|lgamma|log|log10|norm|rand|real|sgn|sin|sinh|sqrt|tan|tanh)\b
|
||||||
|
scope: support.function.gnuplot
|
||||||
|
- match: \b(gprintf|sprintf|strlen|strstrt|substr|system|word|words)\b
|
||||||
|
scope: support.function.string.gnuplot
|
||||||
|
- match: \b(on|off|default|inside|outside|lmargin|rmargin|tmargin|bmargin|at|left|right|center|top|bottom|center|vertical|horizontal|Left|Right|noreverse|noinvert|samplen|spacing|width|height|noautotitle|columnheader|title|noenhanced|nobox|linestyle|ls|linetype|lt|linewidth|lw)\b
|
||||||
|
scope: constant.other.type.gnuplot
|
||||||
|
- match: \b(aed512|aed767|aifm|aqua|bitgraph|cgm|corel|dumb|dxf|eepic|emf|emtex|epslatex|epson_180dpi|epson_60dpi|epson_lx800|fig|gif|gpic|hp2623A|hp2648|hp500c|hpdj|hpgl|hpljii|hppj|imagen|jpeg|kc_tek40xx|km_tek40xx|latex|mf|mif|mp|nec_cp6|okidata|pbm|pcl5|pdf|png|postscript|pslatex|pstex|pstricks|qms|regis|selanar|starc|svg|tandy_60dpi|tek40xx|tek410x|texdraw|tgif|tkcanvas|tpic|unknown|vttek)\b
|
||||||
|
scope: constant.other.terminal.gnuplot
|
||||||
|
- match: \b(u(sing)?|t(it(le)?)?|notit(le)?|w(i(th)?)?|steps|fs(teps)?|notitle|l(i(nes)?)?|linespoints|via)\b
|
||||||
|
scope: keyword.modifier.gnuplot
|
||||||
|
- match: |-
|
||||||
|
(?x:
|
||||||
|
\b # Start with a word boundary
|
||||||
|
(?=\b[\w$]*(\(|.*=)) # Look-ahead for a bracket or equals
|
||||||
|
(?![^(]*\)) # negative look ahead for a closing bracket without an opening one. This stops a from matching in f(a)
|
||||||
|
( # Group variable name
|
||||||
|
[A-Za-z] # A letter
|
||||||
|
[\w$]* # Any word chars or $
|
||||||
|
) # That is it for the name.
|
||||||
|
)
|
||||||
|
comment: user defined function / variable
|
||||||
|
scope: variable.other.gnuplot
|
||||||
|
- match: \b(if)\b
|
||||||
|
scope: keyword.control.gnuplot
|
||||||
|
- match: \b(show)\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.command.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.line.show.gnuplot
|
||||||
|
- meta_content_scope: keyword.line.show.gnuplot
|
||||||
|
- match: (?!\#)($\n?)
|
||||||
|
pop: true
|
||||||
|
- include: main
|
||||||
|
- match: \b(set)\b\s*\b(terminal|term)\b
|
||||||
|
captures:
|
||||||
|
1: keyword.other.command.gnuplot
|
||||||
|
2: keyword.other.setting.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.line.set.terminal.gnuplot
|
||||||
|
- match: (?!\#)($\n?)
|
||||||
|
pop: true
|
||||||
|
- include: main
|
||||||
|
- match: \b(set)\b\s*\b(key)\b
|
||||||
|
captures:
|
||||||
|
1: keyword.other.command.gnuplot
|
||||||
|
2: keyword.other.setting.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.line.set.key.gnuplot
|
||||||
|
- match: (?!\#)($\n?)
|
||||||
|
pop: true
|
||||||
|
- include: main
|
||||||
|
- match: \b(set|unset)\b\s*(?!\b(terminal|key|for)\b)
|
||||||
|
captures:
|
||||||
|
1: keyword.other.command.gnuplot
|
||||||
|
2: keyword.other.setting.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.line.set.gnuplot
|
||||||
|
- meta_content_scope: keyword.line.set.gnuplot
|
||||||
|
- match: (?!\#)($\n?)
|
||||||
|
pop: true
|
||||||
|
- include: main
|
||||||
|
number:
|
||||||
|
- match: |-
|
||||||
|
(?x: # turn on extended mode
|
||||||
|
-? # an optional minus
|
||||||
|
(?:
|
||||||
|
0 # a zero
|
||||||
|
| # ...or...
|
||||||
|
[1-9] # a 1-9 character
|
||||||
|
\d* # followed by zero or more digits
|
||||||
|
)
|
||||||
|
(?:
|
||||||
|
\. # a period
|
||||||
|
\d+ # followed by one or more digits
|
||||||
|
(?:
|
||||||
|
[eE] # an e character
|
||||||
|
[+-]? # followed by an option +/-
|
||||||
|
\d+ # followed by one or more digits
|
||||||
|
)? # make exponent optional
|
||||||
|
)? # make decimal portion optional
|
||||||
|
)
|
||||||
|
comment: borrowed from textmate book
|
||||||
|
scope: constant.numeric.gnuplot
|
||||||
|
operator:
|
||||||
|
- match: \s*(==|~=|>|>=|<|<=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s*
|
||||||
|
comment: Operator symbols
|
||||||
|
scope: keyword.operator.symbols.matlab
|
||||||
|
string_double:
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.begin.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.gnuplot
|
||||||
|
- match: '"'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.end.gnuplot
|
||||||
|
pop: true
|
||||||
|
- match: '\\[\$`"\\\n]'
|
||||||
|
scope: constant.character.escape.gnuplot
|
||||||
|
string_single:
|
||||||
|
- match: "'"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.begin.gnuplot
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.single.gnuplot
|
||||||
|
- match: "'"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.end.gnuplot
|
||||||
|
pop: true
|
||||||
+116
@@ -0,0 +1,116 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# See http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
file_extensions:
|
||||||
|
- log
|
||||||
|
scope: text.log
|
||||||
|
variables:
|
||||||
|
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: (\w+)(=)
|
||||||
|
captures:
|
||||||
|
1: variable.parameter.log
|
||||||
|
2: keyword.operator.assignment.log
|
||||||
|
- match: (')([^']*)(')
|
||||||
|
scope: string.quoted.single.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
3: punctuation.definition.string.end.log
|
||||||
|
- match: (")([^"]*)(")
|
||||||
|
scope: string.quoted.double.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
3: punctuation.definition.string.end.log
|
||||||
|
- include: dates
|
||||||
|
- include: ip_addresses
|
||||||
|
- include: numbers
|
||||||
|
- match: \b(?i:fail(?:ure|ed)?|error|exception)\b
|
||||||
|
scope: markup.error.log
|
||||||
|
- match: \b(?i:warn(?:ing)?)\b
|
||||||
|
scope: markup.warning.log
|
||||||
|
#- include: scope:text.html.markdown#autolink-inet
|
||||||
|
- match: \b\w+:/{2,3}
|
||||||
|
scope: markup.underline.link.scheme.log
|
||||||
|
push: url-host
|
||||||
|
dates:
|
||||||
|
- match: \b\d{4}-\d{2}-\d{2}\b
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
- match: \b\d{4}/\d{2}/\d{2}\b
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
- match: \b(?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)(?:(\.)\d{3})?\b
|
||||||
|
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
ip_addresses:
|
||||||
|
- match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log
|
||||||
|
- match: \d+
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: \.
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
- match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
|
||||||
|
- match: \h{1,4}
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
numbers:
|
||||||
|
- match: \b(0x)(\h+)(?:(\.)(\h+))?\b
|
||||||
|
scope: meta.number.float.hexadecimal.log
|
||||||
|
captures:
|
||||||
|
1: constant.numeric.base.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
3: constant.numeric.value.log punctuation.separator.decimal.log
|
||||||
|
4: constant.numeric.value.log
|
||||||
|
- match: \b\d+(\.)\d+\b
|
||||||
|
scope: meta.number.float.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
- match: \b\d+\b
|
||||||
|
scope: meta.number.integer.log constant.numeric.value.log
|
||||||
|
url-host:
|
||||||
|
- meta_content_scope: markup.underline.link.host.log
|
||||||
|
- match: \[
|
||||||
|
scope: punctuation.section.brackets.begin.log
|
||||||
|
push:
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.brackets.end.log
|
||||||
|
pop: true
|
||||||
|
- include: ip_addresses
|
||||||
|
- match: '[^:/\s]+'
|
||||||
|
- match: ''
|
||||||
|
set: url-after-host
|
||||||
|
url-after-host:
|
||||||
|
- match: (:)(\d+)
|
||||||
|
scope: markup.underline.link.port.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.mapping.port.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
#- include: scope:text.html.markdown#url-escaped-chars
|
||||||
|
- match: (%)\h{2}
|
||||||
|
scope: markup.underline.link.path.log constant.character.escape.url.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.escape.log
|
||||||
|
# After a valid domain, zero or more non-space non-< characters may follow
|
||||||
|
- match: (?=[?!.,:*_~]*[\s<]) # Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link
|
||||||
|
pop: true
|
||||||
|
- match: \( # When an autolink ends in ), we scan the entire autolink for the total number of parentheses. If there is a greater number of closing parentheses than opening ones, we don’t consider the last character part of the autolink, in order to facilitate including an autolink inside a parenthesis
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.underline.link.path.log
|
||||||
|
- match: (?=[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: \)
|
||||||
|
pop: true
|
||||||
|
- match: (?=\)[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: '[^?!.,:*_~\s<&()%]+|\S'
|
||||||
|
scope: markup.underline.link.path.log
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
Vendored
+1
-1
Submodule assets/syntaxes/02_Extra/ssh-config updated: 1ddcb320ac...201816b609
+60
@@ -0,0 +1,60 @@
|
|||||||
|
# SYNTAX TEST "CSV.sublime-syntax"
|
||||||
|
Forename,Surname,House No.,Street,City,Postcode
|
||||||
|
#^^^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^ meta.field-4
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
John,Doe,87,Logon Road,Citiville,TU43 6GH
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^^ meta.field-4
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Jane,Doe,22,"""Fun"" Street","The City, County",FA90 1XA
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^ meta.field-1 string.quoted.double punctuation.definition.string.begin
|
||||||
|
# ^^^^^^^^^^^^^^^^^ meta.field-1 string.quoted.double
|
||||||
|
# ^ meta.field-1 string.quoted.double punctuation.definition.string.end
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Fred,Bloggs,"19","Street
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-3 string.quoted.double
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^ meta.field-4 punctuation.definition.string.begin
|
||||||
|
# ^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
Spanning Multiple ""
|
||||||
|
#^^^^^^^^^^^^^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
Lines",Citee,P0stc0d3
|
||||||
|
#^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^ meta.field-4 punctuation.definition.string.end
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 15.
|
+162
@@ -0,0 +1,162 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
ENVIRONMENT
|
||||||
|
$SYSTEMD_LOG_LEVEL
|
||||||
|
# ^ punctuation.definition.variable
|
||||||
|
# ^^^^^^^^^^^^^^^^^ constant.other
|
||||||
|
systemd reads the log level from this environment variable. This
|
||||||
|
can be overridden with --log-level=.
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
The systemd Homepage[11], systemd-system.conf(5), locale.conf(5)
|
||||||
|
# ^^^^^^^^^^^^^^^^^^^ entity.name.function
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
# SYNTAX TEST "CSV.sublime-syntax"
|
||||||
|
Forename Surname House No. Street City Postcode
|
||||||
|
#^^^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^ meta.field-4
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
John Doe 87 Logon Road Citiville TU43 6GH
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^^ meta.field-4
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Jane Doe 22 """Fun"" Street" "The City County" FA90 1XA
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^ meta.field-3
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^ meta.field-1 string.quoted.double punctuation.definition.string.begin
|
||||||
|
# ^^^^^^^^^^^^^^^^^ meta.field-1 string.quoted.double
|
||||||
|
# ^ meta.field-1 string.quoted.double punctuation.definition.string.end
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Fred Bloggs "19" "Street
|
||||||
|
#^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^ meta.field-2
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^ meta.field-3 string.quoted.double
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^ meta.field-4 punctuation.definition.string.begin
|
||||||
|
# ^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
Spanning Multiple ""
|
||||||
|
#^^^^^^^^^^^^^^^^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^^ constant.character.escape
|
||||||
|
Lines" Citee P0stc0d3
|
||||||
|
#^^^^^ meta.field-4 string.quoted.double
|
||||||
|
# ^ meta.field-4 punctuation.definition.string.end
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^ meta.field-1
|
||||||
|
# ^ punctuation.separator.sequence
|
||||||
|
# ^^^^^^^^ meta.field-2
|
||||||
|
Can't render this file because it contains an unexpected character in line 1 and column 15.
|
+63
@@ -0,0 +1,63 @@
|
|||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: syslog
|
||||||
|
file_extensions:
|
||||||
|
- syslog
|
||||||
|
scope: text.log.syslog
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- match: ^(\w+\s+\d+)\s+(\d{2}:\d{2}:\d{2})
|
||||||
|
scope: meta.datetime.syslog constant.numeric.syslog
|
||||||
|
captures:
|
||||||
|
1: meta.date.syslog
|
||||||
|
2: meta.time.syslog
|
||||||
|
push: loghost
|
||||||
|
- match: ^
|
||||||
|
push: text
|
||||||
|
loghost:
|
||||||
|
- match: '[\w-]+'
|
||||||
|
scope: entity.other.attribute-name.loghost.syslog
|
||||||
|
set: process
|
||||||
|
process:
|
||||||
|
- match: ([\w-]+)(?:(\[)(\d+)(\]))?(:)
|
||||||
|
captures:
|
||||||
|
1: support.function.process.syslog
|
||||||
|
2: punctuation.separator.pid.begin.syslog
|
||||||
|
3: meta.pid.syslog meta.number.integer.syslog constant.numeric.value.syslog
|
||||||
|
4: punctuation.separator.pid.end.syslog
|
||||||
|
5: punctuation.separator.mapping.syslog
|
||||||
|
set: structured-data
|
||||||
|
structured-data:
|
||||||
|
- match: '\['
|
||||||
|
scope: punctuation.section.mapping.begin.syslog
|
||||||
|
push:
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.mapping.end.syslog
|
||||||
|
pop: true
|
||||||
|
- match: \w+
|
||||||
|
scope: variable.parameter.syslog
|
||||||
|
- match: =
|
||||||
|
scope: keyword.operator.assignment.syslog
|
||||||
|
push:
|
||||||
|
- match: '[^\s\]]+'
|
||||||
|
scope: constant.other.syslog
|
||||||
|
pop: true
|
||||||
|
- match: (?=\])
|
||||||
|
pop: true
|
||||||
|
- match: (?=\S)
|
||||||
|
set: text
|
||||||
|
text:
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- match: '<\w+>'
|
||||||
|
scope: constant.language.syslog
|
||||||
|
- match: \b(CMD)\b\s+(\()
|
||||||
|
captures:
|
||||||
|
1: entity.name.label.syslog
|
||||||
|
2: punctuation.section.block.begin.syslog
|
||||||
|
embed: scope:source.shell.bash
|
||||||
|
escape: \)$
|
||||||
|
escape_captures:
|
||||||
|
0: punctuation.section.block.end.syslog
|
||||||
|
- include: scope:text.log
|
||||||
Vendored
BIN
Binary file not shown.
+1
Submodule assets/themes/Coldark added at e44750b2a9
Vendored
-504
@@ -1,504 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<!--
|
|
||||||
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
|
|
||||||
palette number from 00 to 0f, and AA is the special value 00 to indicate
|
|
||||||
that this encoding is being used.
|
|
||||||
-->
|
|
||||||
<key>author</key>
|
|
||||||
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
|
|
||||||
<key>name</key>
|
|
||||||
<string>ANSI Light</string>
|
|
||||||
<key>colorSpaceName</key>
|
|
||||||
<string>sRGB</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>background</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
<key>caret</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
<key>invisibles</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
<key>lineHighlight</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
<key>selection</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
<key>gutter</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
<key>gutterForeground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Text</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>variable.parameter.function</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Comments</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>comment, punctuation.definition.comment</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#02000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Punctuation</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Delimiters</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>none</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Operators</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>keyword.operator</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Keywords</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>keyword</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Variables</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>variable</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Functions</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>entity.name.function, meta.require, support.function.any-method</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#04000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Labels</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>entity.name.label</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#06000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Classes</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>support.class, entity.name.class, entity.name.type.class</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Classes</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>meta.class</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Methods</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>keyword.other.special-method</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#04000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Storage</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>storage</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Support</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>support.function</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#06000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Strings, Inherited Class</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>string, constant.other.symbol, entity.other.inherited-class</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#02000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Integers</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>constant.numeric</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Floats</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>none</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Boolean</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>none</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Constants</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>constant</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Tags</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>entity.name.tag</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#01000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Attributes</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>entity.other.attribute-name</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Attribute IDs</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#04000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Selector</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>meta.selector</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Values</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>none</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Headings</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>fontStyle</key>
|
|
||||||
<string></string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#04000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Units</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>keyword.other.unit</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Bold</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.bold, punctuation.definition.bold</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>fontStyle</key>
|
|
||||||
<string>bold</string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Italic</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.italic, punctuation.definition.italic</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>fontStyle</key>
|
|
||||||
<string>italic</string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Code</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.raw.inline</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#02000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Link Text</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#01000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Link Url</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>meta.link</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Quotes</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.quote</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Inserted</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.inserted</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#02000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Deleted</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.deleted</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#01000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Changed</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>markup.changed</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Colors</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>constant.other.color</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#06000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Regular Expressions</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>string.regexp</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#06000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Escape Characters</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>constant.character.escape</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#06000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Embedded</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>punctuation.section.embedded, variable.interpolation</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#05000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Illegal</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>invalid.illegal</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>background</key>
|
|
||||||
<string>#01000000</string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Broken</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>invalid.broken</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>background</key>
|
|
||||||
<string>#03000000</string>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</array>
|
|
||||||
<key>uuid</key>
|
|
||||||
<string>uuid</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
+12
-86
@@ -3,14 +3,14 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<!--
|
<!--
|
||||||
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
|
The colors in this theme are encoded as #RRGGBBAA where:
|
||||||
palette number from 00 to 0f, and AA is the special value 00 to indicate
|
* If AA is 00, then RR is an ANSI palette number from 00 to 07.
|
||||||
that this encoding is being used.
|
* If AA is 01, the terminal's default fg/bg color is used.
|
||||||
-->
|
-->
|
||||||
<key>author</key>
|
<key>author</key>
|
||||||
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
|
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>ANSI Dark</string>
|
<string>ANSI</string>
|
||||||
<key>colorSpaceName</key>
|
<key>colorSpaceName</key>
|
||||||
<string>sRGB</string>
|
<string>sRGB</string>
|
||||||
<key>settings</key>
|
<key>settings</key>
|
||||||
@@ -19,32 +19,17 @@
|
|||||||
<key>settings</key>
|
<key>settings</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>background</key>
|
<key>background</key>
|
||||||
<string>#00000000</string>
|
<string>#00000001</string>
|
||||||
<key>caret</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
<key>foreground</key>
|
<key>foreground</key>
|
||||||
<string>#07000000</string>
|
<string>#00000001</string>
|
||||||
<key>invisibles</key>
|
<!--
|
||||||
<string>#07000000</string>
|
Explicitly set the gutter color since bat falls back to a
|
||||||
<key>lineHighlight</key>
|
hardcoded DEFAULT_GUTTER_COLOR otherwise.
|
||||||
<string>#07000000</string>
|
-->
|
||||||
<key>selection</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
<key>gutter</key>
|
<key>gutter</key>
|
||||||
<string>#00000000</string>
|
<string>#00000001</string>
|
||||||
<key>gutterForeground</key>
|
<key>gutterForeground</key>
|
||||||
<string>#07000000</string>
|
<string>#00000001</string>
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Text</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>variable.parameter.function</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -58,39 +43,6 @@
|
|||||||
<string>#02000000</string>
|
<string>#02000000</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Punctuation</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Delimiters</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>none</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Operators</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>keyword.operator</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>Keywords</string>
|
<string>Keywords</string>
|
||||||
@@ -102,17 +54,6 @@
|
|||||||
<string>#05000000</string>
|
<string>#05000000</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Variables</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>variable</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>Functions</string>
|
<string>Functions</string>
|
||||||
@@ -146,17 +87,6 @@
|
|||||||
<string>#03000000</string>
|
<string>#03000000</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
|
||||||
<key>name</key>
|
|
||||||
<string>Classes</string>
|
|
||||||
<key>scope</key>
|
|
||||||
<string>meta.class</string>
|
|
||||||
<key>settings</key>
|
|
||||||
<dict>
|
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>name</key>
|
<key>name</key>
|
||||||
<string>Methods</string>
|
<string>Methods</string>
|
||||||
@@ -480,8 +410,6 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>background</key>
|
<key>background</key>
|
||||||
<string>#01000000</string>
|
<string>#01000000</string>
|
||||||
<key>foreground</key>
|
|
||||||
<string>#07000000</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -493,8 +421,6 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>background</key>
|
<key>background</key>
|
||||||
<string>#03000000</string>
|
<string>#03000000</string>
|
||||||
<key>foreground</key>
|
|
||||||
<string>#00000000</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
Vendored
+1
-1
Submodule assets/themes/dracula-sublime updated: 26c57ec282...c2de0acf5a
Vendored
+1
-1
Submodule assets/themes/gruvbox updated: e3db74d0e5...64c47250e5
Vendored
+1
-1
Submodule assets/themes/onehalf updated: 3aa42a39ed...141c775ace
+1
Submodule assets/themes/visual-studio-dark-plus added at 01ee1e8e0d
Vendored
+1
-1
Submodule assets/themes/zenburn updated: cb746f6962...702023d80d
@@ -54,6 +54,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
"assets/manual/bat.1.in",
|
"assets/manual/bat.1.in",
|
||||||
out_dir.join("assets/manual/bat.1"),
|
out_dir.join("assets/manual/bat.1"),
|
||||||
)?;
|
)?;
|
||||||
|
template(
|
||||||
|
&variables,
|
||||||
|
"assets/completions/bat.bash.in",
|
||||||
|
out_dir.join("assets/completions/bat.bash"),
|
||||||
|
)?;
|
||||||
template(
|
template(
|
||||||
&variables,
|
&variables,
|
||||||
"assets/completions/bat.fish.in",
|
"assets/completions/bat.fish.in",
|
||||||
|
|||||||
Vendored
+6
-4
@@ -58,7 +58,8 @@ _bat_:run() {
|
|||||||
_out "$BAT" --version
|
_out "$BAT" --version
|
||||||
_out env | grep '^BAT_\|^PAGER='
|
_out env | grep '^BAT_\|^PAGER='
|
||||||
|
|
||||||
local cache_dir="$($BAT --cache-dir)"
|
local cache_dir
|
||||||
|
cache_dir="$($BAT --cache-dir)"
|
||||||
if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
|
if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
|
||||||
_print_command "$BAT" "--list-languages"
|
_print_command "$BAT" "--list-languages"
|
||||||
echo "Found custom syntax set."
|
echo "Found custom syntax set."
|
||||||
@@ -79,8 +80,8 @@ _bat_config_:run() {
|
|||||||
_bat_wrapper_:run() {
|
_bat_wrapper_:run() {
|
||||||
_bat_wrapper_:detect_wrapper() {
|
_bat_wrapper_:detect_wrapper() {
|
||||||
local bat="$1"
|
local bat="$1"
|
||||||
if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
|
if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then
|
||||||
_out_fence cat "$(which "${bat}")"
|
_out_fence cat "$(command -v "${bat}")"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -104,7 +105,8 @@ _bat_wrapper_function_:run() {
|
|||||||
fi ;;
|
fi ;;
|
||||||
|
|
||||||
*bash* | *zsh*)
|
*bash* | *zsh*)
|
||||||
local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
|
local type
|
||||||
|
type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
|
||||||
if grep 'function' <<< "$type" &> /dev/null; then
|
if grep 'function' <<< "$type" &> /dev/null; then
|
||||||
_out_fence "$SHELL" --login -i -c "declare -f ${command}"
|
_out_fence "$SHELL" --login -i -c "declare -f ${command}"
|
||||||
return
|
return
|
||||||
|
|||||||
+21
-8
@@ -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
|
||||||
@@ -93,6 +95,17 @@ bat f - g # output 'f', then stdin, then 'g'.
|
|||||||
|
|
||||||
### 他のツールとの統合
|
### 他のツールとの統合
|
||||||
|
|
||||||
|
#### `fzf`
|
||||||
|
|
||||||
|
[`fzf`](https://github.com/junegunn/fzf) のプレビューウィンドウに `bat` を使用できます。
|
||||||
|
その場合、`bat` の `--color=always` オプションを用いてカラー出力を強制しなければなりません。
|
||||||
|
また、`--line-range` オプションを用いることで巨大なファイルの読み込み時間を制限できます:
|
||||||
|
```bash
|
||||||
|
fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'
|
||||||
|
```
|
||||||
|
|
||||||
|
詳しくは [`fzf` の `README`](https://github.com/junegunn/fzf#preview-window) を参照してください。
|
||||||
|
|
||||||
#### `find` or `fd`
|
#### `find` or `fd`
|
||||||
|
|
||||||
`find` の `-exec` オプションを使用して、`bat` ですべての検索結果をプレビューできます:
|
`find` の `-exec` オプションを使用して、`bat` ですべての検索結果をプレビューできます:
|
||||||
@@ -152,7 +165,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 +202,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.18.2_amd64.deb # adapt version number and architecture
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Alpine Linux
|
### On Alpine Linux
|
||||||
@@ -391,7 +404,7 @@ bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
|
|||||||
|
|
||||||
### 新しい構文の追加 / 言語の定義
|
### 新しい構文の追加 / 言語の定義
|
||||||
|
|
||||||
`bat` はシンタックスハイライトのための [`syntext`](https://github.com/trishume/syntect/)
|
`bat` はシンタックスハイライトのための [`syntect`](https://github.com/trishume/syntect/)
|
||||||
という素晴らしいライブラリを使用しています。`syntect` は、
|
という素晴らしいライブラリを使用しています。`syntect` は、
|
||||||
[Sublime Text の `.sublime-syntax` ファイル](https://www.sublimetext.com/docs/3/syntax.html)
|
[Sublime Text の `.sublime-syntax` ファイル](https://www.sublimetext.com/docs/3/syntax.html)
|
||||||
とテーマを読み取ることができます。新しい構文を定義するために以下の手順を行います。
|
とテーマを読み取ることができます。新しい構文を定義するために以下の手順を行います。
|
||||||
@@ -628,7 +641,7 @@ cargo install --locked --force
|
|||||||
比較については [このドキュメント](alternatives.md) を参照してください。
|
比較については [このドキュメント](alternatives.md) を参照してください。
|
||||||
|
|
||||||
## ライセンス
|
## ライセンス
|
||||||
Copyright (c) 2018-2020 [bat-developers](https://github.com/sharkdp/bat).
|
Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
`bat` は MIT License 及び Apache License 2.0 の両方の条件の下で配布されています。
|
`bat` は MIT License 及び Apache License 2.0 の両方の条件の下で配布されています。
|
||||||
|
|
||||||
|
|||||||
+464
-205
@@ -1,75 +1,86 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="../doc/logo-header.svg" alt="bat - a cat clone with wings"><br>
|
<img src="../doc/logo-header.svg" alt="bat - a cat clone with wings"><br>
|
||||||
<a href="https://travis-ci.org/sharkdp/bat"><img src="https://travis-ci.org/sharkdp/bat.svg?branch=master" alt="Build Status"></a>
|
<a href="https://github.com/sharkdp/bat/actions?query=workflow%3ACICD"><img src="https://github.com/sharkdp/bat/workflows/CICD/badge.svg" alt="Build Status"></a>
|
||||||
<a href="https://ci.appveyor.com/project/sharkdp/bat"><img src="https://ci.appveyor.com/api/projects/status/cptsmtbiwbnr2vhf/branch/master?svg=true"></a>
|
|
||||||
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
|
||||||
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
|
||||||
|
문법 강조와 Git 통합 기능의 <i>cat(1)</i> 클론
|
||||||
문법 강조와 깃 통합 기능의 <i>cat(1)</i> 클론
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="#문법-강조">주요 기능들</a> •
|
<a href="#문법-강조">주요 기능들</a> •
|
||||||
<a href="#사용법">사용법</a> •
|
<a href="#사용법">사용법</a> •
|
||||||
<a href="#설치">설치</a> •
|
<a href="#설치">설치</a> •
|
||||||
<a href="#커스터마이즈">커스터마이즈</a> •
|
<a href="#사용자화">사용자화</a> •
|
||||||
<a href="#프로젝트-목표와-대안들">프로젝트 목표와 대안들</a> •
|
<a href="#프로젝트-목표와-대안들">프로젝트 목표와 대안들</a> •
|
||||||
번역 [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>][<a href="../doc/README-ja.md">日本語</a>]
|
[<a href="https://github.com/chinanf-boy/bat-zh">中文</a>] [<a href="../doc/README-ja.md">日本語</a>] [<a href="../doc/README-ko.md">한국어</a>] [<a href="../doc/README-ru.md">Русский</a>]
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
### 문법 강조
|
### 문법 강조
|
||||||
|
|
||||||
`bat`은 다양한 프로그래밍 언어와 마크업 언어에 대해 문법 강조(Syntax highlighting)기능을 지원하고 있습니다:
|
`bat`은 다양한 프로그래밍 및 마크업 언어의 문법 강조(syntax highlighting) 기능을
|
||||||
|
지원합니다:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Git 통합
|
### Git 통합
|
||||||
|
|
||||||
`bat`은 `git`을 통해 인덱스와 함께 변경분을 표시합니다 (왼쪽 바를 확인하세요):
|
`bat`은 `git`을 통해 인덱스와 함께 변경분을 표시합니다
|
||||||
|
(왼쪽 사이드바를 확인하세요):
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 표시할 수 없는 문자 처리
|
### 비인쇄 문자 처리
|
||||||
|
|
||||||
`-A`/`--show-all` 옵션을 사용하여 표시할수 없는 문자를 시각화 해줍니다:
|
`-A`/`--show-all` 옵션을 사용하여 비인쇄 문자를 표시 및 강조할 수 있습니다:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 자동 페이징
|
### 자동 페이징
|
||||||
|
|
||||||
하나의 화면에 비해 출력이 너무 큰 경우, `less` 를 이용해 출력들을 연결할 수 있습니다.
|
`bat`은 기본적으로 한 화면에 비해 출력이 큰 경우 `less`와 같은 페이저(pager)로
|
||||||
|
출력을 연결(pipe)합니다.
|
||||||
|
만약 `bat`을 언제나 `cat`처럼 작동하게 하려면 (출력을 페이지하지 않기),
|
||||||
|
`--paging=never` 옵션을 커맨드 라인이나 설정 파일에 넣을 수 있습니다.
|
||||||
|
셸(shell) 설정에서 `cat`을 `bat`의 alias로 사용하려면,
|
||||||
|
`alias cat='bat --paging=never'`를 써서 기본 행동을 유지할 수 있습니다.
|
||||||
|
|
||||||
### 파일 연결
|
### 파일 연결(concatenation)
|
||||||
|
|
||||||
이 뿐만 아니라 파일을 연결할 때도 사용 할 수 있습니다. :wink: `bat`가 인터렉티브 하지 않은(non-interactive)가 감지하면 (예를 들어,다른 프로세스 혹은 파일과 파이프라인을 연결 한 경우) `bat`은 `cat`을 대신하여 동작하며 일반 파일 내용을 표기해줍니다.
|
페이저(pager)를 사용하더라도 `bat`은 파일들을 연결(concatenate)할 수 있습니다
|
||||||
|
:wink:.
|
||||||
|
`bat`이 비대화형(non-interactive) 터미널(예를 들어, 다른 프로세스나 파일에
|
||||||
|
연결(pipe)한 경우)을 감지하면, `bat`은 `--pager` 옵션의 값과 상관없이 `cat`과
|
||||||
|
동일하게 파일 내용을 그대로 출력합니다.
|
||||||
|
|
||||||
## 사용법
|
## 사용법
|
||||||
|
|
||||||
터미널에서 하나의 파일 표시하기
|
터미널에 하나의 파일 표시하기
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> bat README.md
|
> bat README.md
|
||||||
```
|
```
|
||||||
|
|
||||||
여러 파일 한번에 보여주기
|
여러 파일 한 번에 보여주기
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> bat src/*.rs
|
> bat src/*.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
stdin에서 읽고, 자동으로 맞는 문법 강조 적용하기
|
stdin에서 읽고, 자동으로 맞는 문법 결정하기 (참고로, 문법 강조는 파일의 첫
|
||||||
|
줄만으로 문법이 결정될 수 있을 때만 작동합니다.
|
||||||
|
이는 보통 `#!/bin/sh`와 같은 셔뱅(shebang)으로 판단합니다.)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> curl -s https://sh.rustup.rs | bat
|
> curl -s https://sh.rustup.rs | bat
|
||||||
```
|
```
|
||||||
|
|
||||||
stdin에서 읽고, 명시적으로 언어 지정하여 적용하기
|
stdin에서 읽고, 명시적으로 언어 지정하기
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
> yaml2json .travis.yml | json_pp | bat -l json
|
> yaml2json .travis.yml | json_pp | bat -l json
|
||||||
```
|
```
|
||||||
|
|
||||||
표시할 수 없는 문자 처리하기
|
비인쇄 문자 표시 및 강조하기
|
||||||
```bash
|
```bash
|
||||||
> bat -A /etc/hosts
|
> bat -A /etc/hosts
|
||||||
```
|
```
|
||||||
@@ -86,23 +97,38 @@ bat -n main.rs # show line numbers (only)
|
|||||||
bat f - g # output 'f', then stdin, then 'g'.
|
bat f - g # output 'f', then stdin, then 'g'.
|
||||||
```
|
```
|
||||||
|
|
||||||
### 다른 툴과의 통합
|
### 다른 도구들과 통합하기
|
||||||
|
|
||||||
#### `find` 와 `fd`
|
#### `fzf`
|
||||||
|
|
||||||
`find`의 `-exec` 옵션을 사용하여 `bat`의 모든 검색 결과를 미리 볼 수 있습니다:
|
`bat`을 [`fzf`](https://github.com/junegunn/fzf)의 프리뷰로 쓸 수 있습니다.
|
||||||
|
이를 위해서는 `bat`의 `--color=always` 옵션으로 항상 컬러 출력이 나오게 해야
|
||||||
|
합니다.
|
||||||
|
또한 `--line-range` 옵션으로 긴 파일의 로드 시간을 제한할 수 있습니다:
|
||||||
|
```bash
|
||||||
|
fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}'
|
||||||
|
```
|
||||||
|
더 많은 정보는
|
||||||
|
[`fzf`의 `README`](https://github.com/junegunn/fzf#preview-window)를 참고하세요.
|
||||||
|
|
||||||
|
#### `find`와 `fd`
|
||||||
|
|
||||||
|
`find`의 `-exec` 옵션을 사용하여 모든 검색 결과를 `bat`로 미리 볼 수 있습니다:
|
||||||
```bash
|
```bash
|
||||||
find … -exec bat {} +
|
find … -exec bat {} +
|
||||||
```
|
```
|
||||||
|
|
||||||
[`fd`](https://github.com/sharkdp/fd)를 사용하고 있는 경우, `-X`/`--exec-batch` 옵션을 이용하여 동일하게 사용할 수 있습니다:
|
[`fd`](https://github.com/sharkdp/fd)를 사용하는 경우, `-X`/`--exec-batch`
|
||||||
|
옵션을 이용하여 동일하게 사용할 수 있습니다:
|
||||||
```bash
|
```bash
|
||||||
fd … -X bat
|
fd … -X bat
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `ripgrep`
|
#### `ripgrep`
|
||||||
|
|
||||||
[`batgrep`](https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md)과 함께, [`ripgrep`](https://github.com/BurntSushi/ripgrep)의 검색 결과를 `bat`을 이용하여 볼 수 있습니다.
|
[`batgrep`](https://github.com/eth-p/bat-extras/blob/master/doc/batgrep.md)을
|
||||||
|
통해 `bat`로 [`ripgrep`](https://github.com/BurntSushi/ripgrep)의 검색 결과를
|
||||||
|
출력할 수 있습니다.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
batgrep needle src/
|
batgrep needle src/
|
||||||
@@ -110,279 +136,393 @@ batgrep needle src/
|
|||||||
|
|
||||||
#### `tail -f`
|
#### `tail -f`
|
||||||
|
|
||||||
`bat` 과 `tail -f`를 함께 사용하여, 특정 파일을 문법 강조하며 지속적으로 모니터링 할 수 있습니다.
|
`bat`와 `tail -f`를 함께 사용하여 주어진 파일을 문법 강조하며 지속적으로
|
||||||
|
모니터할 수 있습니다.
|
||||||
```bash
|
```bash
|
||||||
tail -f /var/log/pacman.log | bat --paging=never -l log
|
tail -f /var/log/pacman.log | bat --paging=never -l log
|
||||||
```
|
```
|
||||||
이 작업을 하려면 페이징 기능을 꺼야합니다. 또, 자동 감지가 되지 않기 때문에, 적용되어야할 문법을 명시적(`-l log`)으로 지정해야 합니다.
|
참고로 이 작업을 하려면 페이징 기능을 꺼야 합니다.
|
||||||
|
또한 이 경우 문법을 자동 감지할 수 없기 때문에, 적용할 문법을 직접 지정해야
|
||||||
|
합니다 (`-l log`).
|
||||||
|
|
||||||
#### `git`
|
#### `git`
|
||||||
|
|
||||||
`bat`과 `git show`를 함께 사용하여 주어진 파일의 이전 기록을 문법 강조와 함께 볼 수 있습니다:
|
`bat`과 `git show`를 함께 사용하여 주어진 파일의 이전 버전을 올바른 문법 강조로
|
||||||
|
볼 수 있습니다:
|
||||||
```bash
|
```bash
|
||||||
git show v0.6.0:src/main.rs | bat -l rs
|
git show v0.6.0:src/main.rs | bat -l rs
|
||||||
```
|
```
|
||||||
|
|
||||||
diffs 내에서 문법 강조 표시는 현재 지원되지 않습니다. 이 기능은 [`delta`](https://github.com/dandavison/delta)에서 찾아 볼 수 있습니다.
|
#### `git diff`
|
||||||
|
|
||||||
|
`bat`과 `git diff`를 함께 사용하여 수정된 코드 주위의 줄들을 올바른 문법 강조로
|
||||||
|
볼 수 있습니다:
|
||||||
|
```bash
|
||||||
|
batdiff() {
|
||||||
|
git diff --name-only --diff-filter=d | xargs bat --diff
|
||||||
|
}
|
||||||
|
```
|
||||||
|
이것을 별도의 도구로 쓰고 싶다면
|
||||||
|
[`bat-extras`](https://github.com/eth-p/bat-extras)의 `batdiff`를 확인해 보세요.
|
||||||
|
|
||||||
|
Git과 diff의 더 많은 지원을 원한다면
|
||||||
|
[`delta`](https://github.com/dandavison/delta)를 확인해 보세요.
|
||||||
|
|
||||||
#### `xclip`
|
#### `xclip`
|
||||||
|
|
||||||
`bat` 출력에서 라인 넘버와 Git 수정 내역이 같이 있어 파일 내용을 복사하기가 어려울 수도 있습니다. 이 경우에는 `-p`/`--plain` 옵션을 사용 하거나 출력 시 파이프라인으로 `xclip`을 사용하면 됩니다:
|
`bat` 출력에 줄 번호와 Git 수정 내역이 포함되어서 파일의 내용을 복사하기
|
||||||
|
어려울 수 있습니다.
|
||||||
|
이 경우에는 `bat`의 `-p`/`--plain` 옵션을 사용하거나 간단히 `xclip`으로 출력을
|
||||||
|
연결(pipe)하면 됩니다:
|
||||||
```bash
|
```bash
|
||||||
bat main.cpp | xclip
|
bat main.cpp | xclip
|
||||||
```
|
```
|
||||||
`bat` 에서는 리다이렉트된 것으로 감지하여, 파일 내용만 출력합니다.
|
`bat`는 출력이 우회되고 있다는 것을 감지하여 파일 내용 그대로를 출력합니다.
|
||||||
|
|
||||||
#### `man`
|
#### `man`
|
||||||
|
|
||||||
`bat`은 `MANPAGER` 환경 변수 설정을 통해 `man`에 대하여 컬러 페이져를 사용할 수 있습니다:
|
`MANPAGER` 환경 변수 설정을 통해 `bat`을 `man`의 컬러 페이저(pager)로 쓸 수
|
||||||
|
있습니다.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||||
man 2 select
|
man 2 select
|
||||||
```
|
```
|
||||||
|
(Debian이나 Ubuntu를 사용한다면 `bat`을 `batcat`으로 치환하세요.)
|
||||||
|
|
||||||
포매팅 문제가 발생한다면, `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)을 쓸
|
||||||
|
수도 있습니다.
|
||||||
|
|
||||||
|
참고로 [Manpage 문법](../assets/syntaxes/Manpage.sublime-syntax)은 본 저장소에서
|
||||||
|
개발 중에 있으며, 아직 더 손봐야 합니다.
|
||||||
|
|
||||||
참고 : [Manpage syntax](../assets/syntaxes/Manpage.sublime-syntax)는 이 저장소에서 개발되고 있으며, 아직 작업 중 입니다.
|
또한, 이는 Mandoc의 `man` 구현에서
|
||||||
|
[작동하지 않습니다](https://github.com/sharkdp/bat/issues/1145).
|
||||||
|
|
||||||
#### `prettier` / `shfmt` / `rustfmt`
|
#### `prettier` / `shfmt` / `rustfmt`
|
||||||
|
|
||||||
[`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md) 스크립트는 코드를 포맷팅하고 `bat`으로 출력해주는 랩퍼(wrapper) 입니다.
|
[`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.md)
|
||||||
|
스크립트는 코드를 포맷하고 `bat`으로 출력하는 래퍼(wrapper)입니다.
|
||||||
|
|
||||||
|
|
||||||
## 설치
|
## 설치
|
||||||
|
|
||||||
[](https://repology.org/project/bat/versions)
|
[](https://repology.org/project/bat-cat/versions)
|
||||||
|
|
||||||
### On Ubuntu
|
### Ubuntu에서 (`apt` 사용)
|
||||||
*... 그리고 기타 Debian 기반의 Linux 배포판들.*
|
*... 그리고 다른 Debian 기반의 Linux 배포판들에서.*
|
||||||
|
|
||||||
Ubuntu Eoan 19.10 혹은 Debian unstable sid 이후 버전 부터는 [Ubuntu용 `bat` 패키지](https://packages.ubuntu.com/eoan/bat)나 [Debian용 `bat` 패키지](https://packages.debian.org/sid/bat) 를 설치 할 수 있습니다.
|
`bat`은 [Ubuntu](https://packages.ubuntu.com/eoan/bat)와
|
||||||
|
[Debian](https://packages.debian.org/sid/bat) 패키지 배포 과정에 도입되는 중이며,
|
||||||
|
Eoan 19.10 버전의 Ubuntu에서부터 제공됩니다.
|
||||||
|
현재 Debain에서는 불안정한 "Sid" 브랜치에서만 `bat`이 제공됩니다.
|
||||||
|
|
||||||
|
만약 충분히 최신 버전의 Ubuntu/Debian이 설치되어 있다면 간단히 다음을 실행하세요:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apt install bat
|
apt install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
|
**중요**: 만약 `bat`을 이와 같이 설치한다면, ([다른 패키지와의 이름
|
||||||
|
충돌](https://github.com/sharkdp/bat/issues/982)로 인하여) `bat` 대신에
|
||||||
```bash
|
`batcat`이라는 이름의 실행 파일로 설치될 수 있음을 참고하세요.
|
||||||
sudo dpkg -i bat_0.16.0_amd64.deb # adapt version number and architecture
|
이에 따른 문제들과 다른 배포판들과의 일관성을 위하여 `bat -> batcat` symlink
|
||||||
|
혹은 alias를 설정할 수 있습니다:
|
||||||
|
``` bash
|
||||||
|
mkdir -p ~/.local/bin
|
||||||
|
ln -s /usr/bin/batcat ~/.local/bin/bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Alpine Linux
|
### Ubuntu에서 (가장 최신 `.deb` 패키지들 사용)
|
||||||
|
*... 그리고 다른 Debian 기반의 Linux 배포판들에서.*
|
||||||
|
|
||||||
공식 소스를 통해 [`bat` 패키지](https://pkgs.alpinelinux.org/packages?name=bat) 를 설치 할 수 있습니다:
|
만약 여러분이 설치한 Ubuntu/Debian에 패키지가 배포되지 않거나 가장 최신 릴리즈된
|
||||||
|
`bat`을 원한다면, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서
|
||||||
|
다음과 같이 `.deb` 패키지를 받아 설치하세요:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo dpkg -i bat_0.18.2_amd64.deb # adapt version number and architecture
|
||||||
|
```
|
||||||
|
|
||||||
|
### Alpine Linux에서
|
||||||
|
|
||||||
|
적절한 저장소가 활성화되어 있다면, 공식 소스를 통해
|
||||||
|
[`bat` 패키지](https://pkgs.alpinelinux.org/packages?name=bat)를 설치할 수
|
||||||
|
있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
apk add bat
|
apk add bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Arch Linux
|
### Arch Linux에서
|
||||||
|
|
||||||
공식 소스를 통해 [`bat` 패키지](https://www.archlinux.org/packages/community/x86_64/bat/)를 설치할 수 있습니다:
|
공식 소스를 통해
|
||||||
|
[`bat` 패키지](https://www.archlinux.org/packages/community/x86_64/bat/)를
|
||||||
|
설치할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pacman -S bat
|
pacman -S bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Fedora
|
### Fedora에서
|
||||||
|
|
||||||
[공식 Fedora 모듈 저장소](https://docs.fedoraproject.org/en-US/modularity/using-modules/)에서 [`bat` 패키지](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506)을 설치할 수 있습니다:
|
공식
|
||||||
|
[Fedora 모듈](https://docs.fedoraproject.org/en-US/modularity/using-modules/)
|
||||||
|
저장소에서
|
||||||
|
[`bat` 패키지](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506)를
|
||||||
|
설치할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dnf install bat
|
dnf install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Gentoo Linux
|
### Gentoo Linux에서
|
||||||
|
|
||||||
공식 소스를 통해 [`bat` 패키지](https://packages.gentoo.org/packages/sys-apps/bat)를 설치할 수 있습니다.
|
공식 소스를 통해
|
||||||
|
[`bat` 패키지](https://packages.gentoo.org/packages/sys-apps/bat)를 설치할 수
|
||||||
|
있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
emerge sys-apps/bat
|
emerge sys-apps/bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Void Linux
|
### Void Linux에서
|
||||||
|
|
||||||
xbps-install를 이용해 `bat`을 설치할 수 있습니다:
|
xbps-install을 이용해 `bat`을 설치할 수 있습니다:
|
||||||
```bash
|
```bash
|
||||||
xbps-install -S bat
|
xbps-install -S bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On FreeBSD
|
### Termux에서
|
||||||
|
|
||||||
pkg를 이용하여 미리 컴파일된 [`bat` 패키지](https://www.freshports.org/textproc/bat)를 설치할 수 있습니다:
|
pkg를 이용해 `bat`을 설치할 수 있습니다:
|
||||||
|
```bash
|
||||||
|
pkg install bat
|
||||||
|
```
|
||||||
|
|
||||||
|
### FreeBSD에서
|
||||||
|
|
||||||
|
pkg를 이용하여 미리 컴파일된
|
||||||
|
[`bat` 패키지](https://www.freshports.org/textproc/bat)를 설치할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pkg install bat
|
pkg install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
또는 FreeBSD 포트에서 직접 빌드할 수도 있습니다:
|
또는 FreeBSD 포트에서 직접 빌드할 수도 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /usr/ports/textproc/bat
|
cd /usr/ports/textproc/bat
|
||||||
make install
|
make install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Via nix
|
### nix를 써서
|
||||||
|
|
||||||
[nix package manager](https://nixos.org/nix)를 이용해 `bat`을 설치할 수 있습니다:
|
[nix package manager](https://nixos.org/nix)를 이용해 `bat`을 설치할 수
|
||||||
|
있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nix-env -i bat
|
nix-env -i bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On openSUSE
|
### openSUSE에서
|
||||||
|
|
||||||
zypper을 이용해 `bat`을 설치할 수 있습니다:
|
zypper를 이용해 `bat`을 설치할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
zypper install bat
|
zypper install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On macOS
|
### snap 패키지를 써서
|
||||||
|
|
||||||
[Homebrew](http://braumeister.org/formula/bat)를 이용해 `bat`을 설치할 수 있습니다:
|
지금으로서는 추천하는 snap 패키지가 없습니다.
|
||||||
|
제공되는 패키지들이 존재할 수는 있지만, 공식적으로 지원되지 않으며
|
||||||
|
[문제](https://github.com/sharkdp/bat/issues/1519)가 있을 수 있습니다.
|
||||||
|
|
||||||
|
|
||||||
|
### macOS (또는 Linux)에서 Homebrew를 써서
|
||||||
|
|
||||||
|
[macOS의 Homebrew](https://formulae.brew.sh/formula/bat) 또는
|
||||||
|
[Linux의 Homebrew](https://formulae.brew.sh/formula-linux/bat)를 이용하여
|
||||||
|
`bat`을 설치할 수 있습니다.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install bat
|
brew install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
또는 [MacPorts](https://ports.macports.org/port/bat/summary)를 사용할 수도 있습니다:
|
### macOS에서 MacPorts를 써서
|
||||||
|
|
||||||
|
[MacPorts](https://ports.macports.org/port/bat/summary)를 이용하여 `bat`을
|
||||||
|
설치할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
port install bat
|
port install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Windows
|
### Windows에서
|
||||||
|
|
||||||
Windows에서 `bat`을 설치할 수 있는 몇 가지 옵션들이 있습니다. 먼저 `bat`을 설치 한 후, ["Windows에서 사용하기"](#Windows에서-사용하기) 참고하시기 바랍니다.
|
Windows에서 `bat`을 설치할 수 있는 몇 가지 옵션들이 있습니다.
|
||||||
|
먼저 `bat`을 설치한 후,
|
||||||
|
["Windows에서 `bat` 사용하기"](#windows에서-bat-사용하기) 섹션을 살펴보세요.
|
||||||
|
|
||||||
#### With Chocolatey
|
#### 전제 조건
|
||||||
|
|
||||||
[Chocolatey](https://chocolatey.org/packages/Bat)를 이용해 `bat`을 설치할 수 있습니다:
|
[Visual C++ 재배포 가능](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
|
||||||
|
패키지를 설치해야 합니다.
|
||||||
|
|
||||||
|
#### Chocolatey를 써서
|
||||||
|
|
||||||
|
[Chocolatey](https://chocolatey.org/packages/Bat)를 이용해 `bat`을 설치할 수
|
||||||
|
있습니다:
|
||||||
```bash
|
```bash
|
||||||
choco install bat
|
choco install bat
|
||||||
```
|
```
|
||||||
|
|
||||||
#### With Scoop
|
#### Scoop을 써서
|
||||||
|
|
||||||
[scoop](https://scoop.sh/)을 이용해 `bat`을 설치할 수 있습니다:
|
[scoop](https://scoop.sh/)을 이용해 `bat`을 설치할 수 있습니다:
|
||||||
```bash
|
```bash
|
||||||
scoop install bat
|
scoop install bat
|
||||||
```
|
```
|
||||||
[Visual C++ Redistributable 패키지](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)를 같이 설치해 주어야 합니다.
|
|
||||||
|
|
||||||
#### From prebuilt binaries:
|
#### 사전 빌드된 바이너리들로
|
||||||
|
|
||||||
[릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 빌드된 바이너리를 다운받을 수 있습니다.
|
[릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 사전 빌드된
|
||||||
|
바이너리를 다운받을 수 있습니다.
|
||||||
|
|
||||||
[Visual C++ Redistributable 패키지](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)를 같이 설치해 주어야 합니다.
|
[Visual C++ 재배포 가능](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
|
||||||
|
패키지를 설치해야 합니다.
|
||||||
|
|
||||||
### Via Docker
|
### 바이너리들로
|
||||||
|
|
||||||
컨테이너에서 `bat`을 사용할 수 있는 [Docker image](https://hub.docker.com/r/danlynn/bat/)가 있습니다.:
|
[릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다양한 아키텍처를
|
||||||
```bash
|
위해 사전 빌드된 버전들을 확인할 수 있습니다.
|
||||||
docker pull danlynn/bat
|
정적 링크 바이너리들은 파일 이름에 `musl` 이 포함된 아카이브들을 확인하세요.
|
||||||
alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Via Ansible
|
### 소스에서
|
||||||
|
|
||||||
[Ansible](https://www.ansible.com/)을 사용해 `bat`을 설치할 수 있습니다:
|
`bat`의 소스를 빌드하기 위해서는, Rust 1.45 이상이 필요합니다.
|
||||||
|
`cargo`를 이용해 전부 빌드할 수 있습니다:
|
||||||
```bash
|
|
||||||
# Install role on local machine
|
|
||||||
ansible-galaxy install aeimer.install_bat
|
|
||||||
```
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
---
|
|
||||||
# Playbook to install bat
|
|
||||||
- host: all
|
|
||||||
roles:
|
|
||||||
- aeimer.install_bat
|
|
||||||
```
|
|
||||||
|
|
||||||
- [Ansible Galaxy](https://galaxy.ansible.com/aeimer/install_bat)
|
|
||||||
- [GitHub](https://github.com/aeimer/ansible-install-bat)
|
|
||||||
|
|
||||||
다음 배포판들에서 동작합니다:
|
|
||||||
- Debian/Ubuntu
|
|
||||||
- ARM (eg. Raspberry PI)
|
|
||||||
- Arch Linux
|
|
||||||
- Void Linux
|
|
||||||
- FreeBSD
|
|
||||||
- MacOS
|
|
||||||
|
|
||||||
### From binaries
|
|
||||||
|
|
||||||
[릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다양한 환경을 위해 빌드된 버전들을 확인 할 수 있습니다. 정적 링크 바이너리들은 아카이브에서 파일 이름에 `musl` 이 포함 파일로 확인 할 수 있습니다.
|
|
||||||
|
|
||||||
### From source
|
|
||||||
|
|
||||||
`bat`의 소스를 직접 빌드하기 위해서는, Rust 1.36 이상이 필요하며 `cargo`를 이용해 빌드할 수 있습니다.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install --locked bat
|
cargo install --locked bat
|
||||||
```
|
```
|
||||||
|
|
||||||
일부 플랫폼에서는 `llvm` 그리고/또는 `libclang-dev` 설치가 필요할 수도 있습니다.
|
참고로 man 페이지나 셸 자동 완성 파일과 같은 부가 파일들은 이 방법으로 설치될 수
|
||||||
|
없습니다.
|
||||||
|
이것들은 `cargo`에 의해 생성이 되고 (`build` 밑의) cargo 타켓 폴더에서 찾을 수
|
||||||
|
있습니다.
|
||||||
|
|
||||||
## 커스터마이즈
|
## 사용자화
|
||||||
|
|
||||||
### 문법 강조 테마
|
### 문법 강조 테마
|
||||||
|
|
||||||
`bat --list-themes`을 사용하면, 현재 사용 가능한 문법 강조 테마들을 확인할 수 있습니다. `TwoDark` 테마 선택하는 경우, `--theme=TwoDark` 옵션과 함께 `bat`을 사용하거나 환경변수에서 `BAT_THEME`를 `TwoDark`로 세팅해주면 됩니다. 쉘 시작 파일에 `export BAT_THEME="TwoDark"` 를 정의해 계속 사용도 가능합니다. 이 밖에 `bat`의 [설정 파일](#설정-파일)을 이용할 수도 있습니다.
|
`bat --list-themes`을 사용하여 사용 가능한 문법 강조 테마들의 목록을 확인할 수
|
||||||
|
있습니다.
|
||||||
|
`TwoDark` 테마를 선택하려면, `--theme=TwoDark` 옵션과 함께 `bat`을 사용하거나
|
||||||
|
`BAT_THEME` 환경 변수를 `TwoDark`로 설정하세요.
|
||||||
|
셸 시작 파일에 `export BAT_THEME="TwoDark"` 를 정의해 영구적으로 설정할 수
|
||||||
|
있습니다.
|
||||||
|
이 밖에 `bat`의 [설정 파일](#설정-파일)을 이용할 수 있습니다.
|
||||||
|
|
||||||
다른 테마를 미리 보고 싶은경우 다음 명령어와 같이 사용할 수 있습니다.(이 경우 [`fzf`](https://github.com/junegunn/fzf)가 필요합니다.)
|
만약 다른 테마들을 사용하여 특정 파일을 보고 싶다면, 다음 명령어를 쓸 수
|
||||||
|
있습니다(이 경우 [`fzf`](https://github.com/junegunn/fzf)가 필요합니다.)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
|
bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
|
||||||
```
|
```
|
||||||
`bat`의 기본 테마는 어두운 배경색 터미널에 적합합니다. 만일 밝은 배경색을 사용할 경우에는 `GitHub` 이나 `OneHalfLight` 과 같은 테마가 더 잘 어울립니다. 아래 [새로운 테마 추가하기](#새로운-테마-추가하기)에 따라 커스텀 테마를 사용할수도 있습니다.
|
|
||||||
|
`bat`은 기본적으로 어두운 배경에 적합합니다.
|
||||||
|
그러나 밝은 배경의 터미널을 사용한다면 `GitHub`이나 `OneHalfLight`과 같은 테마가
|
||||||
|
더 잘 어울립니다.
|
||||||
|
아래 [새로운 테마 추가하기](#새로운-테마-추가하기) 섹션에 따라 커스텀 테마를
|
||||||
|
사용할 수도 있습니다.
|
||||||
|
|
||||||
|
### 8비트 테마
|
||||||
|
|
||||||
|
`bat`은 트루컬러 지원이 되더라도 항상
|
||||||
|
[8비트 색상](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)을 사용하는
|
||||||
|
세 개의 테마가 있습니다.
|
||||||
|
|
||||||
|
- `ansi`는 어떤 터미널에서도 무난하게 보입니다. 이는 3비트 색상을 사용합니다:
|
||||||
|
검정, 빨강, 녹색, 노랑, 파랑, 마젠타, 시안, 하양.
|
||||||
|
- `base16`은 [base16](https://github.com/chriskempson/base16) 터미널 테마를 위해
|
||||||
|
디자인되었습니다.
|
||||||
|
이는 [base16 스타일 가이드라인](https://github.com/chriskempson/base16/blob/master/styling.md)에
|
||||||
|
따라 4비트 색상(3비트 색상에 밝은 변형 추가)을 사용합니다.
|
||||||
|
- `base16-256`는 [base16-shell](https://github.com/chriskempson/base16-shell)을
|
||||||
|
위해 디자인되었습니다.
|
||||||
|
이는 16부터 21의 일부 밝은 색상을 8비트 색상으로 대치합니다.
|
||||||
|
단지 256-색상 터미널을 쓰지만 base16-shell을 쓰지 않는다고 해서 이것을
|
||||||
|
사용하지 **마십시오**.
|
||||||
|
|
||||||
|
이들 테마는 더 제한적이지만, 트루컬러 테마에 비해 두 장점이 있습니다:
|
||||||
|
|
||||||
|
- 이들은 3비트 혹은 4비트 색상을 쓰는 다른 터미널 소프트웨어와 더 잘
|
||||||
|
어울립니다.
|
||||||
|
- 만약 터미널 테마를 바꾼다면, 이미 화면 상의 `bat`의 출력도 이에 맞추어
|
||||||
|
업데이트됩니다.
|
||||||
|
|
||||||
### 출력 스타일
|
### 출력 스타일
|
||||||
|
|
||||||
`--style` 옵션을 이용하여 `bat`의 출력 스타일을 변경 할 수 있습니다. 예를 들어, `--style=numbers,changes`는 Git 변경분과 라인 넘버에 대해서만 출력하며 눈금과 파일 헤더가 표시되지 않습니다. `BAT_STYLE` 환경 변수로 정의하여 계속해서 사용하거나`bat`의 [설정 파일](#설정-파일)을 사용할 수도 있습니다.
|
`--style` 옵션을 이용하면 `bat`의 출력 모양을 조절할 수 있습니다.
|
||||||
|
예를 들어, `--style=numbers,changes`를 통해 Git 변경분과 줄 번호는 출력하지만
|
||||||
|
격자와 파일 헤더는 출력하지 않을 수 있습니다.
|
||||||
|
`BAT_STYLE` 환경 변수를 정의하여 이러한 수정을 영구적으로 하거나 `bat`의
|
||||||
|
[설정 파일](#설정-파일)을 사용하세요.
|
||||||
|
|
||||||
### 새로운 문법 강조 / 언어 추가하기
|
### 새로운 문법 / 언어 정의 추가하기
|
||||||
|
|
||||||
`bat`은 문법 강조를 위해 [`syntect`](https://github.com/trishume/syntect/) 라이브러리를 사용하고 있습니다. `syntect`는 [Sublime Text의 `.sublime-syntax` 파일](https://www.sublimetext.com/docs/3/syntax.html)과 테마를 읽을 수 있습니다. 새로운 문법 강조를 추가하는 방법은 다음과 같습니다.
|
만약 `bat`에서 특정 문법이 지원되지 않을 경우, 다음의 절차를 통해 현재 `bat`
|
||||||
|
설치본에 새로운 문법을 쉽게 추가할 수 있습니다.
|
||||||
|
|
||||||
우선 문법 정의 파일을 넣을 폴더를 만듭니다:
|
`bat`은 문법 강조를 위해 훌륭한
|
||||||
|
[`syntect`](https://github.com/trishume/syntect/) 라이브러리를 사용합니다.
|
||||||
|
`syntect`는 임의의 [Sublime Text의 `.sublime-syntax`
|
||||||
|
파일](https://www.sublimetext.com/docs/3/syntax.html)과 테마를 읽을 수 있습니다.
|
||||||
|
|
||||||
```bash
|
[Package Control](https://packagecontrol.io/)에 Sublime 문법 패키지를 찾는
|
||||||
mkdir -p "$(bat --config-dir)/syntaxes"
|
방법이 잘 정리되어 있습니다.
|
||||||
cd "$(bat --config-dir)/syntaxes"
|
일단 문법을 찾았다면:
|
||||||
|
|
||||||
# Put new '.sublime-syntax' language definition files
|
1. 문법 정의 파일들을 넣을 폴더를 만듭니다:
|
||||||
# in this folder (or its subdirectories), for example:
|
|
||||||
git clone https://github.com/tellnobody1/sublime-purescript-syntax
|
|
||||||
```
|
|
||||||
|
|
||||||
다음 명령어를 통해 파일을 바이너리 캐시로 파싱합니다.
|
```bash
|
||||||
|
mkdir -p "$(bat --config-dir)/syntaxes"
|
||||||
|
cd "$(bat --config-dir)/syntaxes"
|
||||||
|
|
||||||
```bash
|
# Put new '.sublime-syntax' language definition files
|
||||||
bat cache --build
|
# in this folder (or its subdirectories), for example:
|
||||||
```
|
git clone https://github.com/tellnobody1/sublime-purescript-syntax
|
||||||
|
```
|
||||||
|
|
||||||
마지막으로 `bat --list-languages`을 통해 새로운 언어가 사용 가능한지 확인합니다.
|
2. 이제 다음 명령어를 통해 파일들을 파싱(parse)하여 바이너리 캐시를 만듭니다.
|
||||||
|
|
||||||
기본 설정으로 돌아가려면, 다음 명령어를 이용합니다.:
|
```bash
|
||||||
|
bat cache --build
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
3. 마지막으로, `bat --list-languages`로 새로 추가한 언어가 사용 가능한지
|
||||||
bat cache --clear
|
확인합니다.
|
||||||
```
|
|
||||||
|
만약 기본 설정으로 돌아갈 일이 생긴다면, 다음 명령어를 이용합니다:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bat cache --clear
|
||||||
|
```
|
||||||
|
|
||||||
|
4. 만약 특정 문법이 `bat`에 기본적으로 포함되어 있어야 한다고 생각한다면, 방침과
|
||||||
|
절차를 [여기](../doc/assets.md)서 읽은 후 "문법 요청(syntax request)"을 열어
|
||||||
|
주세요: [문법 요청하기](https://github.com/sharkdp/bat/issues/new?labels=syntax-request&template=syntax_request.md).
|
||||||
|
|
||||||
### 새로운 테마 추가하기
|
### 새로운 테마 추가하기
|
||||||
|
|
||||||
새로운 문법 정의 추가와 매우 유사합니다.
|
이 과정은 새로운 문법 정의 추가 방식과 매우 비슷합니다.
|
||||||
|
|
||||||
먼저, 새로운 문법 강조 테마 폴더를 만듭니다.
|
먼저, 새로운 문법 강조 테마 폴더를 만듭니다.
|
||||||
```bash
|
```bash
|
||||||
mkdir -p "$(bat --config-dir)/themes"
|
mkdir -p "$(bat --config-dir)/themes"
|
||||||
cd "$(bat --config-dir)/themes"
|
cd "$(bat --config-dir)/themes"
|
||||||
@@ -394,32 +534,93 @@ git clone https://github.com/greggb/sublime-snazzy
|
|||||||
bat cache --build
|
bat cache --build
|
||||||
```
|
```
|
||||||
|
|
||||||
마지막으로 `bat --list-themes`을 통해 새로운 테마가 사용 가능한지 확인합니다.
|
마지막으로 `bat --list-themes`을 통해 새로 추가한 테마들이 사용 가능한지
|
||||||
|
확인합니다.
|
||||||
|
|
||||||
### 다른 페이져 사용하기
|
### 파일 타입 설정을 추가하거나 변경하기
|
||||||
|
|
||||||
`bat`은 환경변수 `PAGER`로 사용할 페이져를 명시합니다. 만약 이 변수가 정의되어있지 않다면 `less`가 기본입니다. 만약 다른 페이져를 사용하고 싶다면 `PAGER` 변수를 수정하거나 `BAT_PAGER` 환경 변수로 `PAGER` 대신 정의 할 수도 있습니다.
|
새로운 파일 이름 패턴을 추가하려면 (혹은 이미 존재하는 것을 변경하려면)
|
||||||
|
`--map-syntax` 커맨드 라인 옵션을 사용하세요.
|
||||||
|
이 옵션은 `pattern:syntax` 꼴의 인자를 받습니다.
|
||||||
|
이때 `pattern`은 파일 이름과 절대 파일 경로를 매치할 글로브(glob) 패턴입니다.
|
||||||
|
`syntax` 부분은 지원되는 언어의 전체 이름입니다
|
||||||
|
(`bat --list-languages`를 통해 개요를 확인하세요).
|
||||||
|
|
||||||
만약 커맨드라인 인수로 넘기려면, `PAGER`/`BAT_PAGER` 변수를 정의를 통해 사용 할 수 있습니다. :
|
참고: 이 옵션은 커맨드 라인에 넘겨 주는 것보다는 `bat`의 설정 파일에 넣는 것이
|
||||||
|
좋을 것입니다 (아래를 보세요).
|
||||||
|
|
||||||
|
예시: "INI" 문법 강조를 `.conf` 파일 확장자의 모든 파일에 적용하려면, 다음을
|
||||||
|
사용하세요:
|
||||||
|
```bash
|
||||||
|
--map-syntax='*.conf:INI'
|
||||||
|
```
|
||||||
|
|
||||||
|
예시: `.ignore`(완전 일치)이라는 이름의 모든 파일을 "Git Ignore" 문법으로
|
||||||
|
열려면, 다음을 사용하세요:
|
||||||
|
```bash
|
||||||
|
--map-syntax='.ignore:Git Ignore'
|
||||||
|
```
|
||||||
|
|
||||||
|
예시: `/etc/apache2`의 하위 폴더들에 있는 모든 `.conf` 파일들을 "Apache Conf"
|
||||||
|
문법으로 열려면, 다음을 사용하세요 (이 대응(mapping)은 이미 내장되어 있습니다):
|
||||||
|
```bash
|
||||||
|
--map-syntax='/etc/apache2/**/*.conf:Apache Conf'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 다른 페이저 사용하기
|
||||||
|
|
||||||
|
`bat`은 환경 변수 `PAGER`에 명시된 페이저를 사용합니다.
|
||||||
|
이 변수가 정의되어 있지 않다면, `less`가 기본으로 사용됩니다.
|
||||||
|
만약 다른 페이저를 사용하고 싶다면, `PAGER` 변수를 수정하거나 `BAT_PAGER` 환경
|
||||||
|
변수를 설정하여 `PAGER`의 설정을 오버라이드(override)할 수 있습니다.
|
||||||
|
|
||||||
|
만약 커맨드라인 인수들을 페이저에게 넘겨 주려면, `PAGER`/`BAT_PAGER` 변수로
|
||||||
|
설정할 수 있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export BAT_PAGER="less -RF"
|
export BAT_PAGER="less -RF"
|
||||||
```
|
```
|
||||||
|
|
||||||
환경 변수 대신, `bat`의 [설정 파일](#설정-파일)에서 페이져를 설정 할 수도 있습니다.(`--pager` 옵션)
|
환경 변수를 사용하는 대신, `bat`의 [설정 파일](#설정-파일)로 페이저를 설정할
|
||||||
|
수도 있습니다 (`--pager` 옵션).
|
||||||
|
|
||||||
**참고**: 기본적으로 페이져가 `less`로 설정 되어있다면, `bat`은 다음 옵션들을 받을 수 있습니다: `-R`/`--RAW-CONTROL-CHARS`,
|
**참고**: 기본적으로, 페이저가 `less`로 설정되어 있다면 (그리고 커맨드 라인
|
||||||
`-F`/`--quit-if-one-screen` 그리고 `-X`/`--no-init`. 마지막 옵션(`-X`)은 530 이전 버전에서만 사용됩니다.
|
옵션이 지정되어 있지 않다면), `bat`은 다음 옵션들을 페이저로 넘겨줍니다:
|
||||||
|
`-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen` 그리고 `-X`/`--no-init`.
|
||||||
|
마지막 옵션(`-X`)은 530 이전 버전의 `less`에만 사용됩니다.
|
||||||
|
|
||||||
`-R` 옵션은 ANSI 컬러를 올바르게 해석하기 위해 필요합니다. 두번째 옵션 (`-F`)은 출력 크기가 터미널의 세로 크기보다 작을 경우 즉시 종료되도록 합니다.
|
`-R` 옵션은 ANSI 색상을 올바르게 해석하기 위해 필요합니다.
|
||||||
페이져를 종료하기 위해 `q`를 누를 필요 없기 때문에 작은 파일을 다룰 때 용이합니다. 세번째 옵션(`-X`)는 `less` 이전 버전의 `--quit-if-one-screen` 기능과 함께 버그를 잡을 때 필요합니다. 안타깝게도, `less`의 마우스 휠 지원은 종료합니다.
|
두 번째 옵션(`-F`)은 출력 크기가 터미널의 세로 크기보다 작을 경우 less가 즉시
|
||||||
|
종료되도록 합니다.
|
||||||
|
이는 작은 파일을 다룰 때 페이저를 종료하기 위해 `q`를 누를 필요 없어서
|
||||||
|
편리합니다.
|
||||||
|
세 번째 옵션(`-X`)는 예전 버전의 `less`에 있는 `--quit-if-one-screen` 기능의
|
||||||
|
버그를 고치기 위해 필요합니다.
|
||||||
|
안타깝게도, 이는 `less`의 마우스 휠 지원과 호환되지 않습니다.
|
||||||
|
|
||||||
`less` 예전 버전에서 마우스 휠 기능을 활성화 시키려면, `-R` 옵션을 사용하면 됩니다. (위의 예제처럼, 이 옵션은 quit-if-one-screen 기능을 비활성화 시킵니다.)
|
`less`의 예전 버전에서 마우스 휠 기능을 활성화하려면, `-R` 옵션을 넘겨주세요
|
||||||
530 이하 버전에서는 그대로 사용할 수 있습니다.
|
(위의 예제처럼, 이 옵션은 quit-if-one-screen 기능을 비활성화합니다).
|
||||||
|
less 530과 이후 버전에서는 그대로 사용할 수 있습니다.
|
||||||
|
|
||||||
|
### 들여쓰기
|
||||||
|
|
||||||
|
`bat`은 페이저에 의존하지 않고 탭을 4 스페이스로 확장합니다.
|
||||||
|
이를 변경하려면 간단히 `--tabs` 인자에 표시되기를 원하는 스페이스 개수를
|
||||||
|
추가하세요.
|
||||||
|
|
||||||
|
**참고**: (`bat`의 `--pager` 인자 혹은 `less`의 `LESS` 환경 변수를 통해)
|
||||||
|
페이저의 탭 길이를 지정하는 것은 효과가 없을 것인데, 이는 페이저가 이미
|
||||||
|
스페이스로 확장된 탭을 받기 때문입니다.
|
||||||
|
이 기능은 사이드바에 의한 들여쓰기 문제를 회피하기 위해 추가되었습니다.
|
||||||
|
`bat`을 `--tabs=0`과 함께 호출하면 이를 오버라이드하여 페이저가 탭을 처리하게
|
||||||
|
합니다.
|
||||||
|
|
||||||
### 다크 모드
|
### 다크 모드
|
||||||
|
|
||||||
macOS에서 다크 모드를 사용하고 있다면, OS 테마에 따라 다른 테마를 사용하도록 `bat`의 구성할 수 있습니다. 아래 코드는 라이트 모드에서는 `default` 테마를 다크모드에서는 `Github` 테마를 사용하는 방법입니다.
|
macOS에서 다크 모드를 사용하고 있다면, `bat`가 OS 테마에 따라 다른 테마를
|
||||||
|
사용하도록 구성할 수 있습니다.
|
||||||
|
아래 스니펫은 _다크 모드_에서는 `default` 테마를, _라이트 모드_에서는 `GitHub`
|
||||||
|
테마를 사용하는 방법입니다.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
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)"
|
||||||
@@ -427,57 +628,89 @@ alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /de
|
|||||||
|
|
||||||
## 설정 파일
|
## 설정 파일
|
||||||
|
|
||||||
`bat` 설정 파일로 커스터마이즈 할 수 있습니다. 파일의 위치는 운영 체제에 따라 다릅니다. 아래 커맨드를 통해 시스템의 기본 경로를 알 수 있습니다.
|
`bat`는 설정 파일로도 사용자화 할 수 있습니다.
|
||||||
|
설정 파일의 위치는 운영 체제에 따라 다릅니다.
|
||||||
|
아래 커맨드를 통해 시스템의 기본 경로를 확인할 수 있습니다.
|
||||||
```
|
```
|
||||||
bat --config-file
|
bat --config-file
|
||||||
```
|
```
|
||||||
|
|
||||||
또는, `BAT_CONFIG_PATH` 환경 변수를 사용하여 `bat`의 설정 파일 위치를 지정할 수 있습니다.
|
또는, `BAT_CONFIG_PATH` 환경 변수를 사용하여 `bat`가 설정 파일의 기본 경로
|
||||||
|
이외의 위치를 사용하도록 할 수 있습니다.
|
||||||
```bash
|
```bash
|
||||||
export BAT_CONFIG_PATH="/path/to/bat.conf"
|
export BAT_CONFIG_PATH="/path/to/bat.conf"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 포맷
|
기본 설정 파일은 `--generate-config-file` 옵션으로 생성할 수 있습니다.
|
||||||
|
|
||||||
설정 파일은 명령어 인수들의 리스트 입니다. `bat --help`를 이용하여 가능한 옵션들과 값들을 확인해 볼 수 있습니다. 또, `#` 으로 주석을 추가할수도 있습니다.
|
|
||||||
|
|
||||||
설정 파일의 예:
|
|
||||||
```bash
|
```bash
|
||||||
# Set the theme to "TwoDark"
|
bat --generate-config-file
|
||||||
--theme="TwoDark"
|
|
||||||
|
|
||||||
# Show line numbers, Git modifications and file header (but no grid)
|
|
||||||
--style="numbers,changes,header"
|
|
||||||
|
|
||||||
# Use italic text on the terminal (not supported on all terminals)
|
|
||||||
--italic-text=always
|
|
||||||
|
|
||||||
# Use C++ syntax for .ino files
|
|
||||||
--map-syntax "*.ino:C++"
|
|
||||||
|
|
||||||
# Use ".gitignore"-style highlighting for ".ignore" files
|
|
||||||
--map-syntax ".ignore:Git Ignore"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Windows에서 사용하기
|
### 포맷
|
||||||
|
|
||||||
`bat` 대부분의 경우 Windows에서 기본적으로 잘 작동하지만, 일부 기능에는 추가 적인 구성이 필요할 수 있습니다.
|
설정 파일은 단순히 커맨드 라인 인자들의 리스트입니다.
|
||||||
|
`bat --help`로 가능한 모든 옵션과 값들을 확인하세요.
|
||||||
|
추가적으로, 줄 앞에 `#` 문자를 추가해 주석을 넣을 수 있습니다.
|
||||||
|
|
||||||
### 페이징
|
설정 파일 예시:
|
||||||
|
```bash
|
||||||
|
# "TwoDark" 테마 설정하기
|
||||||
|
--theme="TwoDark"
|
||||||
|
|
||||||
Windows는 `more` 형식의 매우 제한된 페이저만이 포함되어있습니다. `less`용 Windows 바이너리는 [이 홈페이지](http://www.greenwoodsoftware.com/less/download.html)나 [Chocolatey](https://chocolatey.org/packages/Less)에서 다운로드 받을 수 있습니다. 이를 사용하려면 바이너리를 `PATH` 디렉토리에 배치하거나 [환경 변수로 정의](#using-a-different-pager) 하세요. [Chocolatey 패키지](#on-windows)로 `less`를 자동으로 설치할 수 있습니다.
|
# 줄 번호, Git 변경 내용, 파일 헤더 보이기 (격자 없이)
|
||||||
|
--style="numbers,changes,header"
|
||||||
|
|
||||||
|
# 터미널에서 이탤릭체 쓰기 (일부 터미널에서 미지원)
|
||||||
|
--italic-text=always
|
||||||
|
|
||||||
|
# .ino 파일에 C++ 문법 쓰기
|
||||||
|
--map-syntax "*.ino:C++"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Windows에서 `bat` 사용하기
|
||||||
|
|
||||||
|
`bat`는 대부분의 경우 Windows에서 기본적으로 잘 작동하지만, 일부 기능은 추가적인
|
||||||
|
구성이 필요할 수 있습니다.
|
||||||
|
|
||||||
|
#### 전제 조건
|
||||||
|
|
||||||
|
[Visual C++ 재배포 가능](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
|
||||||
|
패키지를 설치해야 합니다.
|
||||||
|
|
||||||
|
### 페이징
|
||||||
|
|
||||||
|
Windows는 `more` 형식의 매우 제한된 페이저만 포함합니다.
|
||||||
|
Windows용 `less` 바이너리는
|
||||||
|
[공식 홈페이지](http://www.greenwoodsoftware.com/less/download.html)나
|
||||||
|
[Chocolatey](https://chocolatey.org/packages/Less)를 통해 다운로드 받을 수
|
||||||
|
있습니다.
|
||||||
|
이를 사용하려면 디렉터리 안의 바이너리를 `PATH`에 넣거나
|
||||||
|
[환경 변수로 정의](#using-a-different-pager)하세요.
|
||||||
|
[Chocolatey 패키지](#on-windows)는 `less`를 자동으로 설치합니다.
|
||||||
|
|
||||||
### 색상
|
### 색상
|
||||||
|
|
||||||
Windows 10은 기본 내장기능으로 [v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)) 이후의 `conhost.exe`(Command Prompt) 와 PowerShell, 그리고 최신 버전의 bash에서 색상을 지원합니다. 이전 버전의 Windows에서는, [ConEmu](https://conemu.github.io/)가 포함 된 [Cmder](http://cmder.net/)를 사용할 수 있습니다 .
|
Windows 10은
|
||||||
|
[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update))부터
|
||||||
|
기본적으로 `conhost.exe`(Command Prompt)와 PowerShell에서 색상을 지원하며,
|
||||||
|
최신 버전의 bash에서도 색상을 지원합니다.
|
||||||
|
이전 버전의 Windows에서는, [ConEmu](https://conemu.github.io/)가 포함된
|
||||||
|
[Cmder](http://cmder.net/)를 사용할 수 있습니다.
|
||||||
|
|
||||||
**참고:** `less`의 Git과 MSYS 버전은 Windows에서 색상을 올바르게 해석하지 않습니다. 다른 페이져가 설치되어 있지 않은 경우, `--paging=never` 하거나 `BAT_PAGER`를 빈 문자열로 설정하여 페이징을 완전히 비활성화 할 수 있습니다 .
|
**참고:** Git과 MSYS 버전의 `less`는 Windows에서 색상을 올바르게 해석하지
|
||||||
|
않습니다.
|
||||||
|
다른 페이저가 설치되어 있지 않은 경우, `--paging=never`을 넘겨주거나
|
||||||
|
`BAT_PAGER`을 빈 문자열로 설정하여 페이징을 완전히 비활성화 할 수 있습니다.
|
||||||
|
|
||||||
### Cygwin
|
### Cygwin
|
||||||
|
|
||||||
Windows에서의 `bat`은 기본적으로 Cygwin의 unix 스타일의 경로(`/cygdrive/*`)를 지원하지 않습니다. cygwin 절대경로를 인자로 받았을 때, `bat`은 다음과 같이 오류를 반환합니다. `:The system cannot find the path specified. (os error 3)`
|
Windows에서의 `bat`은 기본적으로 Cygwin의 unix 스타일 경로(`/cygdrive/*`)를
|
||||||
|
지원하지 않습니다.
|
||||||
|
Cygwin 절대 경로를 인자로 받았을 때, `bat`은 다음과 같은 오류를 반환합니다:
|
||||||
|
`The system cannot find the path specified. (os error 3)`
|
||||||
|
|
||||||
이 경우, wrapper를 만들거나 다음 함수를 `.bash_profile`추가하여 문제를 해결하실 수 있습니다 :
|
이는 wrapper를 만들거나 다음 함수를 `.bash_profile`에 추가하여 해결할 수
|
||||||
|
있습니다:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bat() {
|
bat() {
|
||||||
@@ -493,68 +726,94 @@ bat() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 트러블슈팅
|
## 문제 해결
|
||||||
|
|
||||||
### 터미널과 색상
|
### 터미널과 색상
|
||||||
|
|
||||||
`bat`은 터미널 트루컬러 지원 여부와 상관없이 동작합니다. 하지만, 문법 강조 테마의 색상이 8-bit 컬러에는 최적화 되어 있지 않고 있으며, 24-bit 트루컬러 지원하는 터미널 사용하는 것을 적극 권장합니다.(`terminator`, `konsole`, `iTerm2`, ...). [이 글](https://gist.github.com/XVilka/8346728)에서 24-bit 트루컬러 지원하는 터미널들을 찾아보실 수 있습니다.
|
`bat`은 터미널의 트루컬러 지원 여부와 상관 없이 동작합니다.
|
||||||
|
그러나 대부분 문법 강조 테마의 색상은 8비트 색상에 최적화되어 있지 않습니다.
|
||||||
|
따라서 24비트 트루컬러 지원이 되는 터미널(`terminator`, `konsole`, `iTerm2`,
|
||||||
|
...)을 사용하는 것을 적극 권장합니다.
|
||||||
|
트루컬러를 지원하는 터미널들과 더 자세한 정보는
|
||||||
|
[이 글](https://gist.github.com/XVilka/8346728)에서 찾아보실 수 있습니다.
|
||||||
|
|
||||||
사용하고 있는 터미널에서 `COLORTERM`을 `truecolor` 혹은
|
사용하고 있는 트루컬러 터미널에서 `COLORTERM` 변수를 `truecolor` 혹은
|
||||||
`24bit`으로 설정 되어있는지 확인하세요. 만약 아니라면, `bat`은 24-bit escape sequence를 지원되는지 여부를 판단 할 수 없습니다. (그리고 8-bit 색상으로 돌아갑니다.)
|
`24bit`로 설정되어 있는지 확인하세요.
|
||||||
|
그렇지 않을 경우, `bat`은 24비트 확장열(escape sequence)이 지원되는지 여부를
|
||||||
|
판단할 수 없습니다 (그리고 8비트 색상을 사용합니다).
|
||||||
|
|
||||||
### 라인 숫자와 눈금이 잘 보이지 않는 경우
|
### 줄 번호와 격자가 잘 보이지 않는 경우
|
||||||
|
|
||||||
다른 테마를 사용해 보세요. (`bat --list-themes`에서 테마들을 확인해 볼 수 있습니다.) `OneHalfDark` 과 `OneHalfLight` 테마는 눈금과 선의 색을 밝게 합니다.
|
다른 테마를 사용해 보세요 (`bat --list-themes`에서 목록을 볼 수 있습니다).
|
||||||
|
`OneHalfDark`와 `OneHalfLight` 테마는 더 밝은 눈금과 선의 색상을 사용합니다.
|
||||||
|
|
||||||
### 파일 인코딩
|
### 파일 인코딩
|
||||||
|
|
||||||
`bat`은 기본적으로 UTF-8과 UTF-8을 제공합니다. 다른 파일 인코딩의 경우, 자동 감지 되지 않으므로 UTF-8로 먼저 변환해 주어야 합니다. 이렇게 할 때, `iconv`를 사용 할 수 있습니다. 예를 들어, Latin-1 (ISO-8859-1)로 인코딩된 PHP파일이라면 다음과 같이 사용할 수 있습니다.:
|
`bat`은 기본적으로 UTF-8과 UTF-16을 지원합니다.
|
||||||
|
다른 모든 종류의 파일 인코딩에 대해서는, 일반적으로 인코딩을 자동으로 판별하는
|
||||||
|
방법이 없기 때문에 먼저 UTF-8으로 변환해야 할 수 있습니다.
|
||||||
|
이를 위해 `iconv`를 사용할 수 있습니다.
|
||||||
|
예시: Latin-1(ISO-8859-1)로 인코딩된 PHP 파일은 다음과 같이 처리할 수 있습니다:
|
||||||
``` bash
|
``` bash
|
||||||
iconv -f ISO-8859-1 -t UTF-8 my-file.php | bat
|
iconv -f ISO-8859-1 -t UTF-8 my-file.php | bat
|
||||||
```
|
```
|
||||||
참고: `bat`으로 자동 감지가 되지 않는 경우에는 `-l`/`--language` 옵션을 사용할 수도 있습니다.
|
참고: `bat`으로 문법 자동 감지가 되지 않는 경우에는 `-l`/`--language` 옵션을
|
||||||
|
사용할 수 있습니다.
|
||||||
|
|
||||||
## 배포
|
## 개발
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Recursive clone to retrieve all submodules
|
# 모든 서브모듈을 받기 위해 재귀적으로 복제하기
|
||||||
git clone --recursive https://github.com/sharkdp/bat
|
git clone --recursive https://github.com/sharkdp/bat
|
||||||
|
|
||||||
# Build (debug version)
|
# (디버그 버전) 빌드
|
||||||
cd bat
|
cd bat
|
||||||
cargo build --bins
|
cargo build --bins
|
||||||
|
|
||||||
# Run unit tests and integration tests
|
# 단위 테스트와 통합 테스트 실행
|
||||||
cargo test
|
cargo test
|
||||||
|
|
||||||
# Install (release version)
|
# (배포 버전) 설치
|
||||||
cargo install --locked
|
cargo install --locked
|
||||||
|
|
||||||
# Build a bat binary with modified syntaxes and themes
|
# 수정된 문법과 테마가 적용된 bat 바이너리 빌드
|
||||||
bash assets/create.sh
|
bash assets/create.sh
|
||||||
cargo install --locked --force
|
cargo install --locked --force
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`bat`의 pretty-printing 기능을 라이브러리로 사용하는 애플리케이션을 만들고
|
||||||
|
싶다면, [API 문서](https://docs.rs/bat/)를 살펴보세요.
|
||||||
|
참고로 `bat`에 라이브러리로써 의존한다면, `regex-onig`나 `regex-fancy`를
|
||||||
|
기능으로 사용해야 합니다.
|
||||||
|
|
||||||
|
## 기여하기
|
||||||
|
|
||||||
|
[`CONTRIBUTING.md`](../CONTRIBUTING.md) 가이드를 살펴보세요.
|
||||||
|
|
||||||
## 메인테이너들
|
## 메인테이너들
|
||||||
|
|
||||||
- [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)
|
||||||
|
- [Enselic](https://github.com/Enselic)
|
||||||
|
|
||||||
## 프로젝트 목표와 대안들
|
## 프로젝트 목표와 대안들
|
||||||
|
|
||||||
`bat`은 아래와 같은 목표를 달성하려고 합니다:
|
`bat`은 다음과 같은 목표를 달성하려고 합니다:
|
||||||
|
|
||||||
- 아름답고 발전된 문법 강조 기능
|
- 아름답고 발전된 문법 강조 기능 제공
|
||||||
- Git 연동을 통한 파일 수정 내역 확인
|
- Git과의 연동을 통한 파일 변경 내용 확인
|
||||||
- (POSIX)`cat`의 대체제
|
- (POSIX) `cat`의 대체제
|
||||||
- 사용자 친화적인 CLI 제공
|
- 사용자 친화적인 커맨드 라인 인터페이스 제공
|
||||||
|
|
||||||
|
비슷한 프로그램들을 찾고 있다면 많은 대안들이 있습니다.
|
||||||
비슷한 프로그램들을 찾고 있다면, 많은 대안들이 있습니다. 비교는 [이 문서]((doc/alternatives.md))를 참조해주세요.
|
비교는 [이 문서](../doc/alternatives.md)를 참조해 주세요.
|
||||||
|
|
||||||
## 라이센스
|
## 라이센스
|
||||||
Copyright (c) 2018-2020 [bat-developers](https://github.com/sharkdp/bat).
|
Copyright (c) 2018-2021 [bat-developers](https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
`bat`는 MIT 라이센스 및 Apache 라이센스 2.0의 조건에 따라 배포됩니다.
|
`bat`는 여러분의 선택에 따라 MIT 라이센스 또는 Apache 라이센스 2.0의 조건에 따라
|
||||||
|
배포됩니다.
|
||||||
|
|
||||||
라이센스 세부사항은 [LICENSE-APACHE](LICENSE-APACHE)와 [LICENSE-MIT](LICENSE-MIT)를 참조하세요.
|
라이센스의 세부사항은 [LICENSE-APACHE](../LICENSE-APACHE)와
|
||||||
|
[LICENSE-MIT](../LICENSE-MIT)를 참조하세요.
|
||||||
|
|||||||
+3
-3
@@ -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.18.2_amd64.deb # измените архитектуру и версию
|
||||||
```
|
```
|
||||||
|
|
||||||
### Alpine Linux
|
### Alpine Linux
|
||||||
@@ -341,7 +341,7 @@ ansible-galaxy install aeimer.install_bat
|
|||||||
|
|
||||||
### Из исходников
|
### Из исходников
|
||||||
|
|
||||||
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.40 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
|
Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.45 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install --locked bat
|
cargo install --locked bat
|
||||||
@@ -587,7 +587,7 @@ cargo install --locked --force
|
|||||||
Есть очень много альтернатив `bat`. Смотрите [этот документ](doc/alternatives.md) для сравнения.
|
Есть очень много альтернатив `bat`. Смотрите [этот документ](doc/alternatives.md) для сравнения.
|
||||||
|
|
||||||
## Лицензия
|
## Лицензия
|
||||||
Copyright (c) 2018-2020 [Разработчики bat](https://github.com/sharkdp/bat).
|
Copyright (c) 2018-2021 [Разработчики bat](https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
`bat` распостраняется под лицензями MIT License и Apache License 2.0 (на выбор пользователя).
|
`bat` распостраняется под лицензями MIT License и Apache License 2.0 (на выбор пользователя).
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ if you are not looking for a program like `bat`, this comparison might not be fo
|
|||||||
| Drop-in `cat` replacement | :heavy_check_mark: [*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (:heavy_check_mark:) | :x: | :x: [*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: |
|
| Drop-in `cat` replacement | :heavy_check_mark: [*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (:heavy_check_mark:) | :x: | :x: [*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: |
|
||||||
| Git integration | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
|
| Git integration | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
|
||||||
| Automatic paging | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :x: | :x: |
|
| Automatic paging | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :x: | :x: |
|
||||||
| Languages (circa) | 110 | 300 | 200 | 7 | 80 | 130 | 30 | 130 |
|
| Languages (circa) | 150 | 300 | 200 | 7 | 80 | 130 | 30 | 130 |
|
||||||
| Extensible (languages, themes) | :heavy_check_mark: | (:heavy_check_mark:) | (:heavy_check_mark:) | :x: | (:heavy_check_mark:) | :x: | :x: | :x: |
|
| Extensible (languages, themes) | :heavy_check_mark: | (:heavy_check_mark:) | (:heavy_check_mark:) | :x: | (:heavy_check_mark:) | :x: | :x: | :x: |
|
||||||
| Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (:heavy_check_mark:) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
| Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (:heavy_check_mark:) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||||
| Execution time [ms] (`jquery-3.3.1.js`) | 624 | 789 | 400 | 80 | 300 | 316 | 157 | 695 |
|
| Execution time [ms] (`jquery-3.3.1.js`) | 624 | 789 | 400 | 80 | 300 | 316 | 157 | 695 |
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
## Adding new builtin languages for syntax highlighting
|
||||||
|
|
||||||
|
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
|
||||||
|
in the `.sublime-syntax` format.
|
||||||
|
|
||||||
|
**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
|
||||||
|
which can be included as a submodule (under `assets/syntaxes`).
|
||||||
|
|
||||||
|
2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
|
||||||
|
`bat` binary.
|
||||||
|
|
||||||
|
5. Use `bat --list-languages` to check if the new languages are available.
|
||||||
|
|
||||||
|
6. Add a syntax test for the new language. See [below](#Syntax-tests) for details.
|
||||||
|
|
||||||
|
7. 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`.
|
||||||
|
|
||||||
|
### Syntax tests
|
||||||
|
|
||||||
|
`bat` has a set of syntax highlighting regression tests in `tests/syntax-tests`. The main idea is
|
||||||
|
make sure that we do not run into issues we had in the past where either (1) syntax highlighting
|
||||||
|
for some language is suddenly not working anymore or (2) `bat` suddenly crashes for some input (due
|
||||||
|
to `regex` incompatibilities between `syntect` and Sublime Text).
|
||||||
|
|
||||||
|
In order to add a new test file, please follow these steps (let's take "Ruby" as an example):
|
||||||
|
|
||||||
|
1. Make sure that you are running the **latest version of `bat`** and that `bat` is available on
|
||||||
|
the path. If you are creating a syntax test for a new builtin syntax (see above), make sure that
|
||||||
|
your version of `bat` already has the new syntax builtin.
|
||||||
|
2. Find an example Ruby source file or write one yourself. If possible, the file should aim to be
|
||||||
|
"comprehensive" (i.e. include a lot of the possible syntax), but this is not strictly necessary.
|
||||||
|
A simple file is better than none at all. Also, the files shouldn't be gigantic.
|
||||||
|
3. Save the file in `tests/syntax-tests/source/Ruby` (adapt for your language). The file name could
|
||||||
|
be `test.rb` (adapt extension) but can also be adapted if that is necessary in order for `bat` to
|
||||||
|
highlight it correctly (e.g. `Makefile`).
|
||||||
|
4. If you have copied the file from somewhere else, please make sure that the file *may* be copied
|
||||||
|
under the respective license and that the license is compatible with `bat`s license. If it
|
||||||
|
requires attribution, please add a `LICENSE.md` in the same folder with a text like this:
|
||||||
|
```
|
||||||
|
The `test.rb` file has been added from [enter source here] under the following license:
|
||||||
|
|
||||||
|
[add license text here]
|
||||||
|
```
|
||||||
|
5. Go to `tests/syntax-tests` and run the `update.sh` Bash script. A new file should be generated
|
||||||
|
in the `highlighted` folder (e.g. `highlighted/Ruby/test.rb`).
|
||||||
|
6. Use `cat` or `bat --language=txt` to display the content of this file and make sure that the
|
||||||
|
syntax highlighting looks correct.
|
||||||
|
7. `git add` the new files in the `source` folder as well as the autogenerated files in the
|
||||||
|
`highlighted` folder.
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
Make sure that the local cache does not interfere with the internally stored syntaxes and
|
||||||
|
themes (`bat cache --clear`).
|
||||||
|
|
||||||
|
## Criteria for inclusion of new syntaxes
|
||||||
|
|
||||||
|
* More than 10,000 downloads on packagecontrol.io/
|
||||||
|
|
||||||
|
### Manual modifications
|
||||||
|
|
||||||
|
The following files have been manually modified after converting from a `.tmLanguage` file:
|
||||||
|
|
||||||
|
* `Apache.sublime_syntax`=> removed `.conf` and `.CONF` file types.
|
||||||
|
* `Dart.sublime-syntax` => removed `#regex.dart` include.
|
||||||
|
* `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.
|
||||||
|
* `SML.sublime_syntax` => removed `ml` file type.
|
||||||
|
* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension
|
||||||
|
|
||||||
|
### Non-submodule additions
|
||||||
|
|
||||||
|
* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems
|
||||||
|
* `Nim.sublime-syntax` has been added manually from https://github.com/getzola/zola/blob/master/sublime_syntaxes/Nim.sublime-syntax as there was no suitable Git repository for it. The original syntax seems to originate from https://github.com/Varriount/NimLime
|
||||||
|
* `Rego.sublime-syntax` has been added manually from https://github.com/open-policy-agent/opa/blob/master/misc/syntax/sublime/rego.sublime-syntax
|
||||||
|
as it is not kept in a standalone repository. The file is generated from
|
||||||
|
https://github.com/open-policy-agent/opa/blob/master/misc/syntax/textmate/Rego.tmLanguage
|
||||||
|
* `SML.sublime_syntax` has been added manually from
|
||||||
|
https://github.com/seanjames777/SML-Language-Definitiona as it is not
|
||||||
|
kept in a standalone repository. The file generated is from
|
||||||
|
https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
|
||||||
|
* `Cabal.sublime_syntax` has been added manually from
|
||||||
|
https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
|
||||||
|
* `Lean.sublime-syntax` has been added manually from https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json via conversion.
|
||||||
+1
-1
@@ -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 |
+64
-27
@@ -11,6 +11,7 @@ use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
|
|||||||
use path_abs::PathAbs;
|
use path_abs::PathAbs;
|
||||||
|
|
||||||
use crate::assets_metadata::AssetsMetadata;
|
use crate::assets_metadata::AssetsMetadata;
|
||||||
|
use crate::bat_warning;
|
||||||
use crate::error::*;
|
use crate::error::*;
|
||||||
use crate::input::{InputReader, OpenedInput, OpenedInputKind};
|
use crate::input::{InputReader, OpenedInput, OpenedInputKind};
|
||||||
use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
|
use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
|
||||||
@@ -22,6 +23,23 @@ pub struct HighlightingAssets {
|
|||||||
fallback_theme: Option<&'static str>,
|
fallback_theme: Option<&'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const IGNORED_SUFFIXES: [&str; 10] = [
|
||||||
|
// Editor etc backups
|
||||||
|
"~",
|
||||||
|
".bak",
|
||||||
|
".old",
|
||||||
|
".orig",
|
||||||
|
// Debian and derivatives apt/dpkg backups
|
||||||
|
".dpkg-dist",
|
||||||
|
".dpkg-old",
|
||||||
|
// Red Hat and derivatives rpm backups
|
||||||
|
".rpmnew",
|
||||||
|
".rpmorig",
|
||||||
|
".rpmsave",
|
||||||
|
// Build system input/template files
|
||||||
|
".in",
|
||||||
|
];
|
||||||
|
|
||||||
impl HighlightingAssets {
|
impl HighlightingAssets {
|
||||||
pub fn default_theme() -> &'static str {
|
pub fn default_theme() -> &'static str {
|
||||||
"Monokai Extended"
|
"Monokai Extended"
|
||||||
@@ -37,9 +55,16 @@ impl HighlightingAssets {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let theme_dir = source_dir.join("themes");
|
let theme_dir = source_dir.join("themes");
|
||||||
|
if theme_dir.exists() {
|
||||||
let res = theme_set.add_from_folder(&theme_dir);
|
let res = theme_set.add_from_folder(&theme_dir);
|
||||||
if res.is_err() {
|
if let Err(err) = res {
|
||||||
|
println!(
|
||||||
|
"Failed to load one or more themes from '{}' (reason: '{}')",
|
||||||
|
theme_dir.to_string_lossy(),
|
||||||
|
err,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"No themes were found in '{}', using the default set",
|
"No themes were found in '{}', using the default set",
|
||||||
theme_dir.to_string_lossy()
|
theme_dir.to_string_lossy()
|
||||||
@@ -189,13 +214,12 @@ impl HighlightingAssets {
|
|||||||
match self.theme_set.themes.get(theme) {
|
match self.theme_set.themes.get(theme) {
|
||||||
Some(theme) => theme,
|
Some(theme) => theme,
|
||||||
None => {
|
None => {
|
||||||
if theme != "" {
|
if theme == "ansi-light" || theme == "ansi-dark" {
|
||||||
use ansi_term::Colour::Yellow;
|
bat_warning!("Theme '{}' is deprecated, using 'ansi' instead.", theme);
|
||||||
eprintln!(
|
return self.get_theme("ansi");
|
||||||
"{}: Unknown theme '{}', using default.",
|
}
|
||||||
Yellow.paint("[bat warning]"),
|
if !theme.is_empty() {
|
||||||
theme
|
bat_warning!("Unknown theme '{}', using default.", theme)
|
||||||
);
|
|
||||||
}
|
}
|
||||||
&self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
|
&self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
|
||||||
}
|
}
|
||||||
@@ -266,12 +290,25 @@ impl HighlightingAssets {
|
|||||||
self.syntax_set
|
self.syntax_set
|
||||||
.find_syntax_by_extension(file_name.to_str().unwrap_or_default())
|
.find_syntax_by_extension(file_name.to_str().unwrap_or_default())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
self.syntax_set.find_syntax_by_extension(
|
let file_path = Path::new(file_name);
|
||||||
Path::new(file_name)
|
self.syntax_set
|
||||||
.extension()
|
.find_syntax_by_extension(
|
||||||
.and_then(|x| x.to_str())
|
file_path
|
||||||
.unwrap_or_default(),
|
.extension()
|
||||||
)
|
.and_then(|x| x.to_str())
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
.or_else(|| {
|
||||||
|
if let Some(file_str) = file_path.to_str() {
|
||||||
|
for suffix in IGNORED_SUFFIXES.iter() {
|
||||||
|
if let Some(stripped_filename) = file_str.strip_suffix(suffix) {
|
||||||
|
return self
|
||||||
|
.get_extension_syntax(OsStr::new(stripped_filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +327,7 @@ mod tests {
|
|||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempdir::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
use crate::input::Input;
|
use crate::input::Input;
|
||||||
|
|
||||||
@@ -305,8 +342,7 @@ mod tests {
|
|||||||
SyntaxDetectionTest {
|
SyntaxDetectionTest {
|
||||||
assets: HighlightingAssets::from_binary(),
|
assets: HighlightingAssets::from_binary(),
|
||||||
syntax_mapping: SyntaxMapping::builtin(),
|
syntax_mapping: SyntaxMapping::builtin(),
|
||||||
temp_dir: TempDir::new("bat_syntax_detection_tests")
|
temp_dir: TempDir::new().expect("creation of temporary directory"),
|
||||||
.expect("creation of temporary directory"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,9 +357,9 @@ mod tests {
|
|||||||
writeln!(temp_file, "{}", first_line).unwrap();
|
writeln!(temp_file, "{}", first_line).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let input = Input::ordinary_file(file_path.as_os_str());
|
let input = Input::ordinary_file(&file_path);
|
||||||
let dummy_stdin: &[u8] = &[];
|
let dummy_stdin: &[u8] = &[];
|
||||||
let mut opened_input = input.open(dummy_stdin).unwrap();
|
let mut opened_input = input.open(dummy_stdin, None).unwrap();
|
||||||
|
|
||||||
self.assets
|
self.assets
|
||||||
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
||||||
@@ -335,9 +371,9 @@ mod tests {
|
|||||||
fn syntax_for_file_with_content_os(&self, file_name: &OsStr, first_line: &str) -> String {
|
fn syntax_for_file_with_content_os(&self, file_name: &OsStr, first_line: &str) -> String {
|
||||||
let file_path = self.temp_dir.path().join(file_name);
|
let file_path = self.temp_dir.path().join(file_name);
|
||||||
let input = Input::from_reader(Box::new(BufReader::new(first_line.as_bytes())))
|
let input = Input::from_reader(Box::new(BufReader::new(first_line.as_bytes())))
|
||||||
.with_name(Some(file_path.as_os_str()));
|
.with_name(Some(&file_path));
|
||||||
let dummy_stdin: &[u8] = &[];
|
let dummy_stdin: &[u8] = &[];
|
||||||
let mut opened_input = input.open(dummy_stdin).unwrap();
|
let mut opened_input = input.open(dummy_stdin, None).unwrap();
|
||||||
|
|
||||||
self.assets
|
self.assets
|
||||||
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
||||||
@@ -360,8 +396,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn syntax_for_stdin_with_content(&self, file_name: &str, content: &[u8]) -> String {
|
fn syntax_for_stdin_with_content(&self, file_name: &str, content: &[u8]) -> String {
|
||||||
let input = Input::stdin().with_name(Some(OsStr::new(file_name)));
|
let input = Input::stdin().with_name(Some(file_name));
|
||||||
let mut opened_input = input.open(content).unwrap();
|
let mut opened_input = input.open(content, None).unwrap();
|
||||||
|
|
||||||
self.assets
|
self.assets
|
||||||
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
.get_syntax(None, &mut opened_input, &self.syntax_mapping)
|
||||||
@@ -444,6 +480,7 @@ mod tests {
|
|||||||
assert_eq!(test.syntax_for_file("test.sass"), "Sass");
|
assert_eq!(test.syntax_for_file("test.sass"), "Sass");
|
||||||
assert_eq!(test.syntax_for_file("test.js"), "JavaScript (Babel)");
|
assert_eq!(test.syntax_for_file("test.js"), "JavaScript (Babel)");
|
||||||
assert_eq!(test.syntax_for_file("test.fs"), "F#");
|
assert_eq!(test.syntax_for_file("test.fs"), "F#");
|
||||||
|
assert_eq!(test.syntax_for_file("test.v"), "Verilog");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -515,9 +552,9 @@ mod tests {
|
|||||||
.expect("creation of directory succeeds");
|
.expect("creation of directory succeeds");
|
||||||
symlink(&file_path, &file_path_symlink).expect("creation of symbolic link succeeds");
|
symlink(&file_path, &file_path_symlink).expect("creation of symbolic link succeeds");
|
||||||
|
|
||||||
let input = Input::ordinary_file(file_path_symlink.as_os_str());
|
let input = Input::ordinary_file(&file_path_symlink);
|
||||||
let dummy_stdin: &[u8] = &[];
|
let dummy_stdin: &[u8] = &[];
|
||||||
let mut opened_input = input.open(dummy_stdin).unwrap();
|
let mut opened_input = input.open(dummy_stdin, None).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test.assets
|
test.assets
|
||||||
|
|||||||
+31
-26
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::path::Path;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use atty::{self, Stream};
|
use atty::{self, Stream};
|
||||||
@@ -16,6 +16,7 @@ use console::Term;
|
|||||||
use crate::input::{new_file_input, new_stdin_input};
|
use crate::input::{new_file_input, new_stdin_input};
|
||||||
use bat::{
|
use bat::{
|
||||||
assets::HighlightingAssets,
|
assets::HighlightingAssets,
|
||||||
|
bat_warning,
|
||||||
config::{Config, VisibleLines},
|
config::{Config, VisibleLines},
|
||||||
error::*,
|
error::*,
|
||||||
input::Input,
|
input::Input,
|
||||||
@@ -82,10 +83,9 @@ impl App {
|
|||||||
Some("always") => PagingMode::Always,
|
Some("always") => PagingMode::Always,
|
||||||
Some("never") => PagingMode::Never,
|
Some("never") => PagingMode::Never,
|
||||||
Some("auto") | None => {
|
Some("auto") | None => {
|
||||||
if self.matches.occurrences_of("plain") > 1 {
|
// If we have -pp as an option when in auto mode, the pager should be disabled.
|
||||||
// If we have -pp as an option when in auto mode, the pager should be disabled.
|
let extra_plain = self.matches.occurrences_of("plain") > 1;
|
||||||
PagingMode::Never
|
if extra_plain || self.matches.is_present("no-paging") {
|
||||||
} else if self.matches.is_present("no-paging") {
|
|
||||||
PagingMode::Never
|
PagingMode::Never
|
||||||
} else if inputs.iter().any(Input::is_stdin) {
|
} else if inputs.iter().any(Input::is_stdin) {
|
||||||
// If we are reading from stdin, only enable paging if we write to an
|
// If we are reading from stdin, only enable paging if we write to an
|
||||||
@@ -150,10 +150,10 @@ impl App {
|
|||||||
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
|
wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
|
||||||
match self.matches.value_of("wrap") {
|
match self.matches.value_of("wrap") {
|
||||||
Some("character") => WrappingMode::Character,
|
Some("character") => WrappingMode::Character,
|
||||||
Some("never") => WrappingMode::NoWrapping,
|
Some("never") => WrappingMode::NoWrapping(true),
|
||||||
Some("auto") | None => {
|
Some("auto") | None => {
|
||||||
if style_components.plain() {
|
if style_components.plain() {
|
||||||
WrappingMode::NoWrapping
|
WrappingMode::NoWrapping(false)
|
||||||
} else {
|
} else {
|
||||||
WrappingMode::Character
|
WrappingMode::Character
|
||||||
}
|
}
|
||||||
@@ -163,15 +163,14 @@ impl App {
|
|||||||
} else {
|
} else {
|
||||||
// We don't have the tty width when piping to another program.
|
// We don't have the tty width when piping to another program.
|
||||||
// There's no point in wrapping when this is the case.
|
// There's no point in wrapping when this is the case.
|
||||||
WrappingMode::NoWrapping
|
WrappingMode::NoWrapping(false)
|
||||||
},
|
},
|
||||||
colored_output: self.matches.is_present("force-colorization")
|
colored_output: self.matches.is_present("force-colorization")
|
||||||
|| 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(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -252,16 +248,19 @@ impl App {
|
|||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
let filenames: Option<Vec<&str>> = self
|
let filenames: Option<Vec<&Path>> = self
|
||||||
.matches
|
.matches
|
||||||
.values_of("file-name")
|
.values_of_os("file-name")
|
||||||
.map(|values| values.collect());
|
.map(|values| values.map(Path::new).collect());
|
||||||
|
|
||||||
let mut filenames_or_none: Box<dyn Iterator<Item = _>> = match filenames {
|
let mut filenames_or_none: Box<dyn Iterator<Item = Option<&Path>>> = match filenames {
|
||||||
Some(ref filenames) => Box::new(filenames.iter().map(|name| Some(OsStr::new(*name)))),
|
Some(filenames) => Box::new(filenames.into_iter().map(Some)),
|
||||||
None => Box::new(std::iter::repeat(None)),
|
None => Box::new(std::iter::repeat(None)),
|
||||||
};
|
};
|
||||||
let files: Option<Vec<&OsStr>> = self.matches.values_of_os("FILE").map(|vs| vs.collect());
|
let files: Option<Vec<&Path>> = self
|
||||||
|
.matches
|
||||||
|
.values_of_os("FILE")
|
||||||
|
.map(|vs| vs.map(Path::new).collect());
|
||||||
|
|
||||||
if files.is_none() {
|
if files.is_none() {
|
||||||
return Ok(vec![new_stdin_input(
|
return Ok(vec![new_stdin_input(
|
||||||
@@ -288,8 +287,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 +322,13 @@ 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) {
|
||||||
|
bat_warning!("Style 'rule' is a subset of style 'grid', 'rule' will not be visible.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(styled_components)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-3
@@ -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")
|
||||||
@@ -324,7 +328,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
"Map a glob pattern to an existing syntax name. The glob pattern is matched \
|
"Map a glob pattern to an existing syntax name. The glob pattern is matched \
|
||||||
on the full path and the filename. For example, to highlight *.build files \
|
on the full path and the filename. For example, to highlight *.build files \
|
||||||
with the Python syntax, use -m '*.build:Python'. To highlight files named \
|
with the Python syntax, use -m '*.build:Python'. To highlight files named \
|
||||||
'.myignore' with the Git Ignore syntax, use -m '.myignore:Git Ignore'.",
|
'.myignore' with the Git Ignore syntax, use -m '.myignore:Git Ignore'. Note \
|
||||||
|
that the right-hand side is the *name* of the syntax, not a file extension.",
|
||||||
)
|
)
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
@@ -363,7 +368,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 +383,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 +401,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.",
|
||||||
),
|
),
|
||||||
@@ -472,6 +478,13 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.hidden(true)
|
.hidden(true)
|
||||||
.help("Show bat's cache directory."),
|
.help("Show bat's cache directory."),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("diagnostic")
|
||||||
|
.long("diagnostic")
|
||||||
|
.alias("diagnostics")
|
||||||
|
.hidden_short_help(true)
|
||||||
|
.help("Show diagnostic information for bug reports.")
|
||||||
|
)
|
||||||
.help_message("Print this help message.")
|
.help_message("Print this help message.")
|
||||||
.version_message("Show version information.");
|
.version_message("Show version information.");
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -10,13 +10,12 @@ pub fn config_file() -> PathBuf {
|
|||||||
env::var("BAT_CONFIG_PATH")
|
env::var("BAT_CONFIG_PATH")
|
||||||
.ok()
|
.ok()
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.filter(|config_path| config_path.is_file())
|
|
||||||
.unwrap_or_else(|| PROJECT_DIRS.config_dir().join("config"))
|
.unwrap_or_else(|| PROJECT_DIRS.config_dir().join("config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_config_file() -> bat::error::Result<()> {
|
pub fn generate_config_file() -> bat::error::Result<()> {
|
||||||
let config_file = config_file();
|
let config_file = config_file();
|
||||||
if config_file.exists() {
|
if config_file.is_file() {
|
||||||
println!(
|
println!(
|
||||||
"A config file already exists at: {}",
|
"A config file already exists at: {}",
|
||||||
config_file.to_string_lossy()
|
config_file.to_string_lossy()
|
||||||
@@ -44,8 +43,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.
|
||||||
|
|
||||||
@@ -72,7 +70,14 @@ pub fn generate_config_file() -> bat::error::Result<()> {
|
|||||||
#--map-syntax ".ignore:Git Ignore"
|
#--map-syntax ".ignore:Git Ignore"
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
fs::write(&config_file, default_config)?;
|
fs::write(&config_file, default_config).map_err(|e| {
|
||||||
|
format!(
|
||||||
|
"Failed to create config file at '{}': {}",
|
||||||
|
config_file.to_string_lossy(),
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Success! Config file written to {}",
|
"Success! Config file written to {}",
|
||||||
config_file.to_string_lossy()
|
config_file.to_string_lossy()
|
||||||
@@ -86,7 +91,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>> {
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ impl BatProjectDirs {
|
|||||||
let config_dir_op = env::var_os("XDG_CONFIG_HOME")
|
let config_dir_op = env::var_os("XDG_CONFIG_HOME")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.filter(|p| p.is_absolute())
|
.filter(|p| p.is_absolute())
|
||||||
.or_else(|| dirs::home_dir().map(|d| d.join(".config")));
|
.or_else(|| dirs_next::home_dir().map(|d| d.join(".config")));
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
let config_dir_op = dirs::config_dir();
|
let config_dir_op = dirs_next::config_dir();
|
||||||
|
|
||||||
let config_dir = config_dir_op.map(|d| d.join("bat"))?;
|
let config_dir = config_dir_op.map(|d| d.join("bat"))?;
|
||||||
|
|
||||||
@@ -43,10 +43,10 @@ impl BatProjectDirs {
|
|||||||
let cache_dir_op = env::var_os("XDG_CACHE_HOME")
|
let cache_dir_op = env::var_os("XDG_CACHE_HOME")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.filter(|p| p.is_absolute())
|
.filter(|p| p.is_absolute())
|
||||||
.or_else(|| dirs::home_dir().map(|d| d.join(".cache")));
|
.or_else(|| dirs_next::home_dir().map(|d| d.join(".cache")));
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
let cache_dir_op = dirs::cache_dir();
|
let cache_dir_op = dirs_next::cache_dir();
|
||||||
|
|
||||||
cache_dir_op.map(|d| d.join("bat"))
|
cache_dir_op.map(|d| d.join("bat"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
use bat::input::Input;
|
use bat::input::Input;
|
||||||
use std::ffi::OsStr;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn new_file_input<'a>(file: &'a OsStr, name: Option<&'a OsStr>) -> Input<'a> {
|
pub fn new_file_input<'a>(file: &'a Path, name: Option<&'a Path>) -> Input<'a> {
|
||||||
named(Input::ordinary_file(file), name.or_else(|| Some(file)))
|
named(Input::ordinary_file(file), name.or(Some(file)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_stdin_input(name: Option<&OsStr>) -> Input {
|
pub fn new_stdin_input(name: Option<&Path>) -> Input {
|
||||||
named(Input::stdin(), name)
|
named(Input::stdin(), name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn named<'a>(input: Input<'a>, name: Option<&OsStr>) -> Input<'a> {
|
fn named<'a>(input: Input<'a>, name: Option<&Path>) -> Input<'a> {
|
||||||
if let Some(provided_name) = name {
|
if let Some(provided_name) = name {
|
||||||
let mut input = input.with_name(Some(provided_name));
|
let mut input = input.with_name(Some(provided_name));
|
||||||
input.description_mut().set_kind(Some("File".to_owned()));
|
input.description_mut().set_kind(Some("File".to_owned()));
|
||||||
|
|||||||
+72
-16
@@ -9,7 +9,6 @@ mod directories;
|
|||||||
mod input;
|
mod input;
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{BufReader, Write};
|
use std::io::{BufReader, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -35,7 +34,7 @@ use bat::{
|
|||||||
error::*,
|
error::*,
|
||||||
input::Input,
|
input::Input,
|
||||||
style::{StyleComponent, StyleComponents},
|
style::{StyleComponent, StyleComponents},
|
||||||
MappingTarget,
|
MappingTarget, PagingMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
|
const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
|
||||||
@@ -78,7 +77,9 @@ fn get_syntax_mapping_to_paths<'a>(
|
|||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_languages(config: &Config) -> Result<()> {
|
pub fn get_languages(config: &Config) -> Result<String> {
|
||||||
|
let mut result: String = String::new();
|
||||||
|
|
||||||
let assets = assets_from_cache_or_binary()?;
|
let assets = assets_from_cache_or_binary()?;
|
||||||
let mut languages = assets
|
let mut languages = assets
|
||||||
.syntaxes()
|
.syntaxes()
|
||||||
@@ -119,12 +120,9 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let stdout = io::stdout();
|
|
||||||
let mut stdout = stdout.lock();
|
|
||||||
|
|
||||||
if config.loop_through {
|
if config.loop_through {
|
||||||
for lang in languages {
|
for lang in languages {
|
||||||
writeln!(stdout, "{}:{}", lang.name, lang.file_extensions.join(","))?;
|
result += &format!("{}:{}\n", lang.name, lang.file_extensions.join(","));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let longest = languages
|
let longest = languages
|
||||||
@@ -145,7 +143,7 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for lang in languages {
|
for lang in languages {
|
||||||
write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
|
result += &format!("{:width$}{}", lang.name, separator, width = longest);
|
||||||
|
|
||||||
// Number of characters on this line so far, wrap before `desired_width`
|
// Number of characters on this line so far, wrap before `desired_width`
|
||||||
let mut num_chars = 0;
|
let mut num_chars = 0;
|
||||||
@@ -156,20 +154,20 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
|||||||
let new_chars = word.len() + comma_separator.len();
|
let new_chars = word.len() + comma_separator.len();
|
||||||
if num_chars + new_chars >= desired_width {
|
if num_chars + new_chars >= desired_width {
|
||||||
num_chars = 0;
|
num_chars = 0;
|
||||||
write!(stdout, "\n{:width$}{}", "", separator, width = longest)?;
|
result += &format!("\n{:width$}{}", "", separator, width = longest);
|
||||||
}
|
}
|
||||||
|
|
||||||
num_chars += new_chars;
|
num_chars += new_chars;
|
||||||
write!(stdout, "{}", style.paint(&word[..]))?;
|
result += &format!("{}", style.paint(&word[..]));
|
||||||
if extension.peek().is_some() {
|
if extension.peek().is_some() {
|
||||||
write!(stdout, "{}", comma_separator)?;
|
result += comma_separator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(stdout)?;
|
result += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn theme_preview_file<'a>() -> Input<'a> {
|
fn theme_preview_file<'a>() -> Input<'a> {
|
||||||
@@ -200,6 +198,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
|
|||||||
.ok();
|
.ok();
|
||||||
writeln!(stdout)?;
|
writeln!(stdout)?;
|
||||||
}
|
}
|
||||||
|
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",
|
||||||
|
PROJECT_DIRS.config_dir().join("themes").to_string_lossy()
|
||||||
|
)?;
|
||||||
} else {
|
} else {
|
||||||
for theme in assets.themes() {
|
for theme in assets.themes() {
|
||||||
writeln!(stdout, "{}", theme)?;
|
writeln!(stdout, "{}", theme)?;
|
||||||
@@ -220,6 +226,50 @@ fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
|
|||||||
fn run() -> Result<bool> {
|
fn run() -> Result<bool> {
|
||||||
let app = App::new()?;
|
let app = App::new()?;
|
||||||
|
|
||||||
|
if app.matches.is_present("diagnostic") {
|
||||||
|
use bugreport::{bugreport, collector::*, format::Markdown};
|
||||||
|
let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
|
||||||
|
.unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less".
|
||||||
|
|
||||||
|
let report = bugreport!()
|
||||||
|
.info(SoftwareVersion::default())
|
||||||
|
.info(OperatingSystem::default())
|
||||||
|
.info(CommandLine::default())
|
||||||
|
.info(EnvironmentVariables::list(&[
|
||||||
|
"SHELL",
|
||||||
|
"PAGER",
|
||||||
|
"LESS",
|
||||||
|
"BAT_PAGER",
|
||||||
|
"BAT_CACHE_PATH",
|
||||||
|
"BAT_CONFIG_PATH",
|
||||||
|
"BAT_OPTS",
|
||||||
|
"BAT_STYLE",
|
||||||
|
"BAT_TABS",
|
||||||
|
"BAT_THEME",
|
||||||
|
"XDG_CONFIG_HOME",
|
||||||
|
"XDG_CACHE_HOME",
|
||||||
|
"COLORTERM",
|
||||||
|
"NO_COLOR",
|
||||||
|
"MANPAGER",
|
||||||
|
]))
|
||||||
|
.info(FileContent::new("Config file", config_file()))
|
||||||
|
.info(CompileTimeInformation::default());
|
||||||
|
|
||||||
|
let mut report = if let Ok(resolved_path) = grep_cli::resolve_binary(pager) {
|
||||||
|
report.info(CommandOutput::new(
|
||||||
|
"Less version",
|
||||||
|
resolved_path,
|
||||||
|
&["--version"],
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
report
|
||||||
|
};
|
||||||
|
|
||||||
|
report.print::<Markdown>();
|
||||||
|
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
match app.matches.subcommand() {
|
match app.matches.subcommand() {
|
||||||
("cache", Some(cache_matches)) => {
|
("cache", Some(cache_matches)) => {
|
||||||
// If there is a file named 'cache' in the current working directory,
|
// If there is a file named 'cache' in the current working directory,
|
||||||
@@ -229,7 +279,7 @@ fn run() -> Result<bool> {
|
|||||||
run_cache_subcommand(cache_matches)?;
|
run_cache_subcommand(cache_matches)?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
let inputs = vec![Input::ordinary_file(OsStr::new("cache"))];
|
let inputs = vec![Input::ordinary_file("cache")];
|
||||||
let config = app.config(&inputs)?;
|
let config = app.config(&inputs)?;
|
||||||
|
|
||||||
run_controller(inputs, &config)
|
run_controller(inputs, &config)
|
||||||
@@ -240,8 +290,14 @@ fn run() -> Result<bool> {
|
|||||||
let config = app.config(&inputs)?;
|
let config = app.config(&inputs)?;
|
||||||
|
|
||||||
if app.matches.is_present("list-languages") {
|
if app.matches.is_present("list-languages") {
|
||||||
list_languages(&config)?;
|
let languages: String = get_languages(&config)?;
|
||||||
Ok(true)
|
let inputs: Vec<Input> = vec![Input::from_reader(Box::new(languages.as_bytes()))];
|
||||||
|
let plain_config = Config {
|
||||||
|
style_components: StyleComponents::new(StyleComponent::Plain.components(false)),
|
||||||
|
paging_mode: PagingMode::QuitIfOneScreen,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
run_controller(inputs, &plain_config)
|
||||||
} else if app.matches.is_present("list-themes") {
|
} else if app.matches.is_present("list-themes") {
|
||||||
list_themes(&config)?;
|
list_themes(&config)?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|||||||
@@ -84,6 +84,15 @@ pub struct Config<'a> {
|
|||||||
pub highlighted_lines: HighlightedLineRanges,
|
pub highlighted_lines: HighlightedLineRanges,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "application", feature = "paging"))]
|
||||||
|
pub fn get_pager_executable(config_pager: Option<&str>) -> Option<String> {
|
||||||
|
if let Ok(Some(pager)) = crate::pager::get_pager(config_pager) {
|
||||||
|
Some(pager.bin)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default_config_should_include_all_lines() {
|
fn default_config_should_include_all_lines() {
|
||||||
use crate::line_range::RangeCheckResult;
|
use crate::line_range::RangeCheckResult;
|
||||||
|
|||||||
+17
-4
@@ -14,6 +14,8 @@ use crate::output::OutputType;
|
|||||||
use crate::paging::PagingMode;
|
use crate::paging::PagingMode;
|
||||||
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
||||||
|
|
||||||
|
use clircle::Clircle;
|
||||||
|
|
||||||
pub struct Controller<'a> {
|
pub struct Controller<'a> {
|
||||||
config: &'a Config<'a>,
|
config: &'a Config<'a>,
|
||||||
assets: &'a HighlightingAssets,
|
assets: &'a HighlightingAssets,
|
||||||
@@ -54,7 +56,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"))]
|
||||||
@@ -63,6 +68,12 @@ impl<'b> Controller<'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let attached_to_pager = output_type.is_pager();
|
let attached_to_pager = output_type.is_pager();
|
||||||
|
let stdout_identifier = if cfg!(windows) || attached_to_pager {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
clircle::Identifier::stdout()
|
||||||
|
};
|
||||||
|
|
||||||
let writer = output_type.handle()?;
|
let writer = output_type.handle()?;
|
||||||
let mut no_errors: bool = true;
|
let mut no_errors: bool = true;
|
||||||
|
|
||||||
@@ -76,7 +87,7 @@ impl<'b> Controller<'b> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (index, input) in inputs.into_iter().enumerate() {
|
for (index, input) in inputs.into_iter().enumerate() {
|
||||||
match input.open(io::stdin().lock()) {
|
match input.open(io::stdin().lock(), stdout_identifier.as_ref()) {
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
print_error(&error, writer);
|
print_error(&error, writer);
|
||||||
no_errors = false;
|
no_errors = false;
|
||||||
@@ -144,7 +155,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,
|
||||||
@@ -194,6 +205,8 @@ impl<'b> Controller<'b> {
|
|||||||
let mut first_range: bool = true;
|
let mut first_range: bool = true;
|
||||||
let mut mid_range: bool = false;
|
let mut mid_range: bool = false;
|
||||||
|
|
||||||
|
let style_snip = self.config.style_components.snip();
|
||||||
|
|
||||||
while reader.read_line(&mut line_buffer)? {
|
while reader.read_line(&mut line_buffer)? {
|
||||||
match line_ranges.check(line_number) {
|
match line_ranges.check(line_number) {
|
||||||
RangeCheckResult::BeforeOrBetweenRanges => {
|
RangeCheckResult::BeforeOrBetweenRanges => {
|
||||||
@@ -204,7 +217,7 @@ impl<'b> Controller<'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RangeCheckResult::InRange => {
|
RangeCheckResult::InRange => {
|
||||||
if self.config.style_components.snip() {
|
if style_snip {
|
||||||
if first_range {
|
if first_range {
|
||||||
first_range = false;
|
first_range = false;
|
||||||
mid_range = true;
|
mid_range = true;
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
#![cfg(feature = "git")]
|
#![cfg(feature = "git")]
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ pub enum LineChange {
|
|||||||
|
|
||||||
pub type LineChanges = HashMap<u32, LineChange>;
|
pub type LineChanges = HashMap<u32, LineChange>;
|
||||||
|
|
||||||
pub fn get_git_diff(filename: &OsStr) -> Option<LineChanges> {
|
pub fn get_git_diff(filename: &Path) -> Option<LineChanges> {
|
||||||
let repo = Repository::discover(&filename).ok()?;
|
let repo = Repository::discover(&filename).ok()?;
|
||||||
|
|
||||||
let repo_path_absolute = fs::canonicalize(repo.workdir()?).ok()?;
|
let repo_path_absolute = fs::canonicalize(repo.workdir()?).ok()?;
|
||||||
|
|||||||
@@ -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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+58
-23
@@ -1,7 +1,9 @@
|
|||||||
use std::ffi::{OsStr, OsString};
|
use std::convert::TryFrom;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, BufRead, BufReader, Read};
|
use std::io::{self, BufRead, BufReader, Read};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use clircle::{Clircle, Identifier};
|
||||||
use content_inspector::{self, ContentType};
|
use content_inspector::{self, ContentType};
|
||||||
|
|
||||||
use crate::error::*;
|
use crate::error::*;
|
||||||
@@ -67,7 +69,7 @@ impl InputDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum InputKind<'a> {
|
pub(crate) enum InputKind<'a> {
|
||||||
OrdinaryFile(OsString),
|
OrdinaryFile(PathBuf),
|
||||||
StdIn,
|
StdIn,
|
||||||
CustomReader(Box<dyn Read + 'a>),
|
CustomReader(Box<dyn Read + 'a>),
|
||||||
}
|
}
|
||||||
@@ -84,7 +86,7 @@ impl<'a> InputKind<'a> {
|
|||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub(crate) struct InputMetadata {
|
pub(crate) struct InputMetadata {
|
||||||
pub(crate) user_provided_name: Option<OsString>,
|
pub(crate) user_provided_name: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Input<'a> {
|
pub struct Input<'a> {
|
||||||
@@ -94,7 +96,7 @@ pub struct Input<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum OpenedInputKind {
|
pub(crate) enum OpenedInputKind {
|
||||||
OrdinaryFile(OsString),
|
OrdinaryFile(PathBuf),
|
||||||
StdIn,
|
StdIn,
|
||||||
CustomReader,
|
CustomReader,
|
||||||
}
|
}
|
||||||
@@ -107,8 +109,12 @@ pub(crate) struct OpenedInput<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Input<'a> {
|
impl<'a> Input<'a> {
|
||||||
pub fn ordinary_file(path: &OsStr) -> Self {
|
pub fn ordinary_file(path: impl AsRef<Path>) -> Self {
|
||||||
let kind = InputKind::OrdinaryFile(path.to_os_string());
|
Self::_ordinary_file(path.as_ref())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _ordinary_file(path: &Path) -> Self {
|
||||||
|
let kind = InputKind::OrdinaryFile(path.to_path_buf());
|
||||||
Input {
|
Input {
|
||||||
description: kind.description(),
|
description: kind.description(),
|
||||||
metadata: InputMetadata::default(),
|
metadata: InputMetadata::default(),
|
||||||
@@ -135,17 +141,16 @@ impl<'a> Input<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_stdin(&self) -> bool {
|
pub fn is_stdin(&self) -> bool {
|
||||||
if let InputKind::StdIn = self.kind {
|
matches!(self.kind, InputKind::StdIn)
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
|
pub fn with_name(self, provided_name: Option<impl AsRef<Path>>) -> Self {
|
||||||
match provided_name {
|
self._with_name(provided_name.as_ref().map(|it| it.as_ref()))
|
||||||
Some(name) => self.description.name = name.to_string_lossy().to_string(),
|
}
|
||||||
None => {}
|
|
||||||
|
fn _with_name(mut self, provided_name: Option<&Path>) -> Self {
|
||||||
|
if let Some(name) = provided_name {
|
||||||
|
self.description.name = name.to_string_lossy().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
|
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
|
||||||
@@ -160,25 +165,55 @@ impl<'a> Input<'a> {
|
|||||||
&mut self.description
|
&mut self.description
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn open<R: BufRead + 'a>(self, stdin: R) -> Result<OpenedInput<'a>> {
|
pub(crate) fn open<R: BufRead + 'a>(
|
||||||
|
self,
|
||||||
|
stdin: R,
|
||||||
|
stdout_identifier: Option<&Identifier>,
|
||||||
|
) -> Result<OpenedInput<'a>> {
|
||||||
let description = self.description().clone();
|
let description = self.description().clone();
|
||||||
match self.kind {
|
match self.kind {
|
||||||
InputKind::StdIn => Ok(OpenedInput {
|
InputKind::StdIn => {
|
||||||
kind: OpenedInputKind::StdIn,
|
if let Some(stdout) = stdout_identifier {
|
||||||
description,
|
let input_identifier = Identifier::try_from(clircle::Stdio::Stdin)
|
||||||
metadata: self.metadata,
|
.map_err(|e| format!("Stdin: Error identifying file: {}", e))?;
|
||||||
reader: InputReader::new(stdin),
|
if stdout.surely_conflicts_with(&input_identifier) {
|
||||||
}),
|
return Err("IO circle detected. The input from stdin is also an output. Aborting to avoid infinite loop.".into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(OpenedInput {
|
||||||
|
kind: OpenedInputKind::StdIn,
|
||||||
|
description,
|
||||||
|
metadata: self.metadata,
|
||||||
|
reader: InputReader::new(stdin),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
InputKind::OrdinaryFile(path) => Ok(OpenedInput {
|
InputKind::OrdinaryFile(path) => Ok(OpenedInput {
|
||||||
kind: OpenedInputKind::OrdinaryFile(path.clone()),
|
kind: OpenedInputKind::OrdinaryFile(path.clone()),
|
||||||
description,
|
description,
|
||||||
metadata: self.metadata,
|
metadata: self.metadata,
|
||||||
reader: {
|
reader: {
|
||||||
let file = File::open(&path)
|
let mut file = File::open(&path)
|
||||||
.map_err(|e| format!("'{}': {}", path.to_string_lossy(), e))?;
|
.map_err(|e| format!("'{}': {}", path.to_string_lossy(), e))?;
|
||||||
if file.metadata()?.is_dir() {
|
if file.metadata()?.is_dir() {
|
||||||
return Err(format!("'{}' is a directory.", path.to_string_lossy()).into());
|
return Err(format!("'{}' is a directory.", path.to_string_lossy()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(stdout) = stdout_identifier {
|
||||||
|
let input_identifier = Identifier::try_from(file).map_err(|e| {
|
||||||
|
format!("{}: Error identifying file: {}", path.to_string_lossy(), e)
|
||||||
|
})?;
|
||||||
|
if stdout.surely_conflicts_with(&input_identifier) {
|
||||||
|
return Err(format!(
|
||||||
|
"IO circle detected. The input from '{}' is also an output. Aborting to avoid infinite loop.",
|
||||||
|
path.to_string_lossy()
|
||||||
|
)
|
||||||
|
.into());
|
||||||
|
}
|
||||||
|
file = input_identifier.into_inner().expect("The file was lost in the clircle::Identifier, this should not have happened...");
|
||||||
|
}
|
||||||
|
|
||||||
InputReader::new(BufReader::new(file))
|
InputReader::new(BufReader::new(file))
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
+19
-3
@@ -1,16 +1,19 @@
|
|||||||
#![cfg(feature = "paging")]
|
#![cfg(feature = "paging")]
|
||||||
|
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn retrieve_less_version() -> Option<usize> {
|
pub fn retrieve_less_version(less_path: &dyn AsRef<OsStr>) -> Option<usize> {
|
||||||
let cmd = Command::new("less").arg("--version").output().ok()?;
|
let resolved_path = grep_cli::resolve_binary(less_path.as_ref()).ok()?;
|
||||||
|
|
||||||
|
let cmd = Command::new(resolved_path).arg("--version").output().ok()?;
|
||||||
parse_less_version(&cmd.stdout)
|
parse_less_version(&cmd.stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_less_version(output: &[u8]) -> Option<usize> {
|
fn parse_less_version(output: &[u8]) -> Option<usize> {
|
||||||
if output.starts_with(b"less ") {
|
if output.starts_with(b"less ") {
|
||||||
let version = std::str::from_utf8(&output[5..]).ok()?;
|
let version = std::str::from_utf8(&output[5..]).ok()?;
|
||||||
let end = version.find(' ')?;
|
let end = version.find(|c: char| !c.is_ascii_digit())?;
|
||||||
version[..end].parse::<usize>().ok()
|
version[..end].parse::<usize>().ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -56,6 +59,19 @@ Home page: http://www.greenwoodsoftware.com/less";
|
|||||||
assert_eq!(Some(551), parse_less_version(output));
|
assert_eq!(Some(551), parse_less_version(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_less_version_581_2() {
|
||||||
|
let output = b"less 581.2 (PCRE2 regular expressions)
|
||||||
|
Copyright (C) 1984-2021 Mark Nudelman
|
||||||
|
|
||||||
|
less comes with NO WARRANTY, to the extent permitted by law.
|
||||||
|
For information about the terms of redistribution,
|
||||||
|
see the file named README in the less distribution.
|
||||||
|
Home page: https://greenwoodsoftware.com/less";
|
||||||
|
|
||||||
|
assert_eq!(Some(581), parse_less_version(output));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_less_version_wrong_program() {
|
fn test_parse_less_version_wrong_program() {
|
||||||
let output = b"more from util-linux 2.34";
|
let output = b"more from util-linux 2.34";
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
//! .unwrap();
|
//! .unwrap();
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
mod macros;
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
pub mod assets_metadata;
|
pub mod assets_metadata;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
@@ -31,6 +33,8 @@ mod less;
|
|||||||
pub mod line_range;
|
pub mod line_range;
|
||||||
mod output;
|
mod output;
|
||||||
#[cfg(feature = "paging")]
|
#[cfg(feature = "paging")]
|
||||||
|
mod pager;
|
||||||
|
#[cfg(feature = "paging")]
|
||||||
pub(crate) mod paging;
|
pub(crate) mod paging;
|
||||||
mod preprocessor;
|
mod preprocessor;
|
||||||
mod pretty_printer;
|
mod pretty_printer;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#[macro_export]
|
||||||
|
macro_rules! bat_warning {
|
||||||
|
($($arg:tt)*) => ({
|
||||||
|
use ansi_term::Colour::Yellow;
|
||||||
|
eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*));
|
||||||
|
})
|
||||||
|
}
|
||||||
+82
-85
@@ -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,108 +26,100 @@ 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(
|
||||||
use std::env;
|
single_screen_action: SingleScreenAction,
|
||||||
use std::ffi::OsString;
|
wrapping_mode: WrappingMode,
|
||||||
use std::path::PathBuf;
|
pager_from_config: Option<&str>,
|
||||||
|
) -> Result<Self> {
|
||||||
|
use crate::pager::{self, PagerKind, PagerSource};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
let mut replace_arguments_to_less = false;
|
let pager_opt =
|
||||||
|
pager::get_pager(pager_from_config).chain_err(|| "Could not parse pager command.")?;
|
||||||
|
|
||||||
let pager_from_env = match (env::var("BAT_PAGER"), env::var("PAGER")) {
|
let pager = match pager_opt {
|
||||||
(Ok(bat_pager), _) => Some(bat_pager),
|
Some(pager) => pager,
|
||||||
(_, Ok(pager)) => {
|
None => return Ok(OutputType::stdout()),
|
||||||
// less needs to be called with the '-R' option in order to properly interpret the
|
|
||||||
// ANSI color sequences printed by bat. If someone has set PAGER="less -F", we
|
|
||||||
// therefore need to overwrite the arguments and add '-R'.
|
|
||||||
//
|
|
||||||
// We only do this for PAGER (as it is not specific to 'bat'), not for BAT_PAGER
|
|
||||||
// or bats '--pager' command line option.
|
|
||||||
replace_arguments_to_less = true;
|
|
||||||
Some(pager)
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let pager_from_config = pager_from_config.map(|p| p.to_string());
|
if pager.kind == PagerKind::Bat {
|
||||||
|
return Err(ErrorKind::InvalidPagerValueBat.into());
|
||||||
if pager_from_config.is_some() {
|
|
||||||
replace_arguments_to_less = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let pager = pager_from_config
|
let resolved_path = match grep_cli::resolve_binary(&pager.bin) {
|
||||||
.or(pager_from_env)
|
Ok(path) => path,
|
||||||
.unwrap_or_else(|| String::from("less"));
|
Err(_) => {
|
||||||
|
return Ok(OutputType::stdout());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let pagerflags =
|
let mut p = Command::new(resolved_path);
|
||||||
shell_words::split(&pager).chain_err(|| "Could not parse pager command.")?;
|
let args = pager.args;
|
||||||
|
|
||||||
match pagerflags.split_first() {
|
if pager.kind == PagerKind::Less {
|
||||||
Some((pager_name, args)) => {
|
// less needs to be called with the '-R' option in order to properly interpret the
|
||||||
let mut pager_path = PathBuf::from(pager_name);
|
// ANSI color sequences printed by bat. If someone has set PAGER="less -F", we
|
||||||
|
// therefore need to overwrite the arguments and add '-R'.
|
||||||
|
//
|
||||||
|
// We only do this for PAGER (as it is not specific to 'bat'), not for BAT_PAGER
|
||||||
|
// or bats '--pager' command line option.
|
||||||
|
let replace_arguments_to_less = pager.source == PagerSource::EnvVarPager;
|
||||||
|
|
||||||
if pager_path.file_stem() == Some(&OsString::from("bat")) {
|
if args.is_empty() || replace_arguments_to_less {
|
||||||
pager_path = PathBuf::from("less");
|
p.arg("--RAW-CONTROL-CHARS");
|
||||||
|
if single_screen_action == SingleScreenAction::Quit {
|
||||||
|
p.arg("--quit-if-one-screen");
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
|
if wrapping_mode == WrappingMode::NoWrapping(true) {
|
||||||
|
p.arg("--chop-long-lines");
|
||||||
|
}
|
||||||
|
|
||||||
let mut process = if is_less {
|
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
|
||||||
let mut p = Command::new(&pager_path);
|
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
|
||||||
if args.is_empty() || replace_arguments_to_less {
|
//
|
||||||
p.arg("--RAW-CONTROL-CHARS");
|
// See: http://www.greenwoodsoftware.com/less/news.530.html
|
||||||
if quit_if_one_screen {
|
//
|
||||||
p.arg("--quit-if-one-screen");
|
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
|
||||||
}
|
// is not needed anymore.
|
||||||
|
match retrieve_less_version(&pager.bin) {
|
||||||
// Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older
|
None => {
|
||||||
// versions of 'less'. Unfortunately, it also breaks mouse-wheel support.
|
p.arg("--no-init");
|
||||||
//
|
|
||||||
// See: http://www.greenwoodsoftware.com/less/news.530.html
|
|
||||||
//
|
|
||||||
// For newer versions (530 or 558 on Windows), we omit '--no-init' as it
|
|
||||||
// is not needed anymore.
|
|
||||||
match retrieve_less_version() {
|
|
||||||
None => {
|
|
||||||
p.arg("--no-init");
|
|
||||||
}
|
|
||||||
Some(version)
|
|
||||||
if (version < 530 || (cfg!(windows) && version < 558)) =>
|
|
||||||
{
|
|
||||||
p.arg("--no-init");
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.args(args);
|
|
||||||
}
|
}
|
||||||
p.env("LESSCHARSET", "UTF-8");
|
Some(version) if (version < 530 || (cfg!(windows) && version < 558)) => {
|
||||||
p
|
p.arg("--no-init");
|
||||||
} else {
|
}
|
||||||
let mut p = Command::new(&pager_path);
|
_ => {}
|
||||||
p.args(args);
|
}
|
||||||
p
|
} else {
|
||||||
};
|
p.args(args);
|
||||||
|
|
||||||
Ok(process
|
|
||||||
.stdin(Stdio::piped())
|
|
||||||
.spawn()
|
|
||||||
.map(OutputType::Pager)
|
|
||||||
.unwrap_or_else(|_| OutputType::stdout()))
|
|
||||||
}
|
}
|
||||||
None => Ok(OutputType::stdout()),
|
p.env("LESSCHARSET", "UTF-8");
|
||||||
}
|
} else {
|
||||||
|
p.args(args);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(p.stdin(Stdio::piped())
|
||||||
|
.spawn()
|
||||||
|
.map(OutputType::Pager)
|
||||||
|
.unwrap_or_else(|_| OutputType::stdout()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn stdout() -> Self {
|
pub(crate) fn stdout() -> Self {
|
||||||
@@ -127,11 +128,7 @@ impl OutputType {
|
|||||||
|
|
||||||
#[cfg(feature = "paging")]
|
#[cfg(feature = "paging")]
|
||||||
pub(crate) fn is_pager(&self) -> bool {
|
pub(crate) fn is_pager(&self) -> bool {
|
||||||
if let OutputType::Pager(_) = self {
|
matches!(self, OutputType::Pager(_))
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "paging"))]
|
#[cfg(not(feature = "paging"))]
|
||||||
|
|||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
use shell_words::ParseError;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
/// If we use a pager, this enum tells us from where we were told to use it.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub(crate) enum PagerSource {
|
||||||
|
/// From --config
|
||||||
|
Config,
|
||||||
|
|
||||||
|
/// From the env var BAT_PAGER
|
||||||
|
EnvVarBatPager,
|
||||||
|
|
||||||
|
/// From the env var PAGER
|
||||||
|
EnvVarPager,
|
||||||
|
|
||||||
|
/// No pager was specified, default is used
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// We know about some pagers, for example 'less'. This is a list of all pagers we know about
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub(crate) enum PagerKind {
|
||||||
|
/// bat
|
||||||
|
Bat,
|
||||||
|
|
||||||
|
/// less
|
||||||
|
Less,
|
||||||
|
|
||||||
|
/// more
|
||||||
|
More,
|
||||||
|
|
||||||
|
/// most
|
||||||
|
Most,
|
||||||
|
|
||||||
|
/// A pager we don't know about
|
||||||
|
Unknown,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PagerKind {
|
||||||
|
fn from_bin(bin: &str) -> PagerKind {
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
match Path::new(bin)
|
||||||
|
.file_stem()
|
||||||
|
.map(|s| s.to_string_lossy())
|
||||||
|
.as_deref()
|
||||||
|
{
|
||||||
|
Some("bat") => PagerKind::Bat,
|
||||||
|
Some("less") => PagerKind::Less,
|
||||||
|
Some("more") => PagerKind::More,
|
||||||
|
Some("most") => PagerKind::Most,
|
||||||
|
_ => PagerKind::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A pager such as 'less', and from where we got it.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct Pager {
|
||||||
|
/// The pager binary
|
||||||
|
pub bin: String,
|
||||||
|
|
||||||
|
/// The pager binary arguments (that we might tweak)
|
||||||
|
pub args: Vec<String>,
|
||||||
|
|
||||||
|
/// What pager this is
|
||||||
|
pub kind: PagerKind,
|
||||||
|
|
||||||
|
/// From where this pager comes
|
||||||
|
pub source: PagerSource,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pager {
|
||||||
|
fn new(bin: &str, args: &[String], kind: PagerKind, source: PagerSource) -> Pager {
|
||||||
|
Pager {
|
||||||
|
bin: String::from(bin),
|
||||||
|
args: args.to_vec(),
|
||||||
|
kind,
|
||||||
|
source,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns what pager to use, after looking at both config and environment variables.
|
||||||
|
pub(crate) fn get_pager(config_pager: Option<&str>) -> Result<Option<Pager>, ParseError> {
|
||||||
|
let bat_pager = env::var("BAT_PAGER");
|
||||||
|
let pager = env::var("PAGER");
|
||||||
|
|
||||||
|
let (cmd, source) = match (config_pager, &bat_pager, &pager) {
|
||||||
|
(Some(config_pager), _, _) => (config_pager, PagerSource::Config),
|
||||||
|
(_, Ok(bat_pager), _) => (bat_pager.as_str(), PagerSource::EnvVarBatPager),
|
||||||
|
(_, _, Ok(pager)) => (pager.as_str(), PagerSource::EnvVarPager),
|
||||||
|
_ => ("less", PagerSource::Default),
|
||||||
|
};
|
||||||
|
|
||||||
|
let parts = shell_words::split(cmd)?;
|
||||||
|
match parts.split_first() {
|
||||||
|
Some((bin, args)) => {
|
||||||
|
let kind = PagerKind::from_bin(bin);
|
||||||
|
|
||||||
|
let use_less_instead = if source == PagerSource::EnvVarPager {
|
||||||
|
// 'more' and 'most' do not supports colors; automatically use
|
||||||
|
// 'less' instead if the problematic pager came from the
|
||||||
|
// generic PAGER env var.
|
||||||
|
// If PAGER=bat, silently use 'less' instead to prevent
|
||||||
|
// recursion.
|
||||||
|
// Never silently use 'less' if BAT_PAGER or --pager has been
|
||||||
|
// specified.
|
||||||
|
matches!(kind, PagerKind::More | PagerKind::Most | PagerKind::Bat)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Some(if use_less_instead {
|
||||||
|
let no_args = vec![];
|
||||||
|
Pager::new("less", &no_args, PagerKind::Less, PagerSource::EnvVarPager)
|
||||||
|
} else {
|
||||||
|
Pager::new(bin, args, kind, source)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
None => Ok(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// line feed
|
// line feed
|
||||||
'\x0A' => output.push('␊'),
|
'\x0A' => output.push_str("␊\x0A"),
|
||||||
// carriage return
|
// carriage return
|
||||||
'\x0D' => output.push('␍'),
|
'\x0D' => output.push('␍'),
|
||||||
// null
|
// null
|
||||||
|
|||||||
+38
-62
@@ -1,5 +1,5 @@
|
|||||||
use std::ffi::OsStr;
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
use console::Term;
|
use console::Term;
|
||||||
use syntect::parsing::SyntaxReference;
|
use syntect::parsing::SyntaxReference;
|
||||||
@@ -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,
|
||||||
}
|
}
|
||||||
@@ -39,10 +40,11 @@ pub struct PrettyPrinter<'a> {
|
|||||||
|
|
||||||
impl<'a> PrettyPrinter<'a> {
|
impl<'a> PrettyPrinter<'a> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut config = Config::default();
|
let config = Config {
|
||||||
|
colored_output: true,
|
||||||
config.colored_output = true;
|
true_color: true,
|
||||||
config.true_color = true;
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
PrettyPrinter {
|
PrettyPrinter {
|
||||||
inputs: vec![],
|
inputs: vec![],
|
||||||
@@ -70,7 +72,7 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a file which should be pretty-printed
|
/// Add a file which should be pretty-printed
|
||||||
pub fn input_file(&mut self, path: impl AsRef<OsStr>) -> &mut Self {
|
pub fn input_file(&mut self, path: impl AsRef<Path>) -> &mut Self {
|
||||||
self.input(Input::from_file(path).kind("File"))
|
self.input(Input::from_file(path).kind("File"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +80,7 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
pub fn input_files<I, P>(&mut self, paths: I) -> &mut Self
|
pub fn input_files<I, P>(&mut self, paths: I) -> &mut Self
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = P>,
|
I: IntoIterator<Item = P>,
|
||||||
P: AsRef<OsStr>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
self.inputs(paths.into_iter().map(Input::from_file))
|
self.inputs(paths.into_iter().map(Input::from_file))
|
||||||
}
|
}
|
||||||
@@ -89,48 +91,17 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add STDIN as an input (with customized name)
|
|
||||||
#[deprecated]
|
|
||||||
pub fn input_stdin_with_name(&mut self, name: impl AsRef<OsStr>) -> &mut Self {
|
|
||||||
self.inputs
|
|
||||||
.push(Input::from_stdin().name(name).kind("File"));
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add a byte string as an input
|
/// Add a byte string as an input
|
||||||
pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self {
|
pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self {
|
||||||
self.input_from_reader(content)
|
self.input_from_reader(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a byte string as an input (with customized name)
|
|
||||||
#[deprecated]
|
|
||||||
#[allow(deprecated)]
|
|
||||||
pub fn input_from_bytes_with_name(
|
|
||||||
&mut self,
|
|
||||||
content: &'a [u8],
|
|
||||||
name: impl AsRef<OsStr>,
|
|
||||||
) -> &mut Self {
|
|
||||||
self.input_from_reader_with_name(content, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add a custom reader as an input
|
/// Add a custom reader as an input
|
||||||
pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self {
|
pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self {
|
||||||
self.inputs.push(Input::from_reader(reader));
|
self.inputs.push(Input::from_reader(reader));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a custom reader as an input (with customized name)
|
|
||||||
#[deprecated]
|
|
||||||
pub fn input_from_reader_with_name<R: Read + 'a>(
|
|
||||||
&mut self,
|
|
||||||
reader: R,
|
|
||||||
name: impl AsRef<OsStr>,
|
|
||||||
) -> &mut Self {
|
|
||||||
self.inputs
|
|
||||||
.push(Input::from_reader(reader).name(name).kind("File"));
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Specify the syntax file which should be used (default: auto-detect)
|
/// Specify the syntax file which should be used (default: auto-detect)
|
||||||
pub fn language(&mut self, language: &'a str) -> &mut Self {
|
pub fn language(&mut self, language: &'a str) -> &mut Self {
|
||||||
self.config.language = Some(language);
|
self.config.language = Some(language);
|
||||||
@@ -179,21 +150,17 @@ 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(feature = "git")]
|
||||||
not(feature = "git"),
|
|
||||||
deprecated(
|
|
||||||
note = "Using vcs_modification_markers without the 'git' feature has no effect. \
|
|
||||||
The function will be removed (for non-'git' use cases) in the future."
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
pub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self {
|
pub fn vcs_modification_markers(&mut self, yes: bool) -> &mut Self {
|
||||||
#[cfg(feature = "git")]
|
self.active_style_components.vcs_modification_markers = yes;
|
||||||
{
|
|
||||||
self.active_style_components.vcs_modification_markers = yes;
|
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,6 +252,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);
|
||||||
}
|
}
|
||||||
@@ -310,6 +280,12 @@ impl<'a> PrettyPrinter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for PrettyPrinter<'_> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An input source for the pretty printer.
|
/// An input source for the pretty printer.
|
||||||
pub struct Input<'a> {
|
pub struct Input<'a> {
|
||||||
input: input::Input<'a>,
|
input: input::Input<'a>,
|
||||||
@@ -322,13 +298,13 @@ impl<'a> Input<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A new input from a file.
|
/// A new input from a file.
|
||||||
pub fn from_file(path: impl AsRef<OsStr>) -> Self {
|
pub fn from_file(path: impl AsRef<Path>) -> Self {
|
||||||
input::Input::ordinary_file(path.as_ref()).into()
|
input::Input::ordinary_file(path).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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.
|
||||||
@@ -338,8 +314,8 @@ impl<'a> Input<'a> {
|
|||||||
|
|
||||||
/// The filename of the input.
|
/// The filename of the input.
|
||||||
/// This affects syntax detection and changes the default header title.
|
/// This affects syntax detection and changes the default header title.
|
||||||
pub fn name(mut self, name: impl AsRef<OsStr>) -> Self {
|
pub fn name(mut self, name: impl AsRef<Path>) -> Self {
|
||||||
self.input = self.input.with_name(Some(name.as_ref()));
|
self.input = self.input.with_name(Some(name));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +328,7 @@ impl<'a> Input<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The title for the input (e.g. "http://example.com/example.txt")
|
/// The title for the input (e.g. "Descriptive title")
|
||||||
/// This defaults to the file name.
|
/// This defaults to the file name.
|
||||||
pub fn title(mut self, title: impl Into<String>) -> Self {
|
pub fn title(mut self, title: impl Into<String>) -> Self {
|
||||||
self.input.description_mut().set_title(Some(title.into()));
|
self.input.description_mut().set_title(Some(title.into()));
|
||||||
@@ -360,14 +336,14 @@ impl<'a> Input<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<Input<'a>> for input::Input<'a> {
|
impl<'a> From<input::Input<'a>> for Input<'a> {
|
||||||
fn into(self) -> Input<'a> {
|
fn from(input: input::Input<'a>) -> Self {
|
||||||
Input { input: self }
|
Self { input }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Into<input::Input<'a>> for Input<'a> {
|
impl<'a> From<Input<'a>> for input::Input<'a> {
|
||||||
fn into(self) -> input::Input<'a> {
|
fn from(Input { input }: Input<'a>) -> Self {
|
||||||
self.input
|
input
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-24
@@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> {
|
|||||||
if self.config.show_nonprintable {
|
if self.config.show_nonprintable {
|
||||||
let line = replace_nonprintable(line_buffer, self.config.tab_width);
|
let line = replace_nonprintable(line_buffer, self.config.tab_width);
|
||||||
write!(handle, "{}", line)?;
|
write!(handle, "{}", line)?;
|
||||||
if line_buffer.last() == Some(&b'\n') {
|
|
||||||
writeln!(handle)?;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
handle.write_all(line_buffer)?
|
handle.write_all(line_buffer)?
|
||||||
};
|
};
|
||||||
@@ -200,13 +197,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 +253,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 +285,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 +308,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
|
||||||
)?;
|
)?;
|
||||||
@@ -417,7 +424,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Line contents.
|
// Line contents.
|
||||||
if self.config.wrapping_mode == WrappingMode::NoWrapping {
|
if matches!(self.config.wrapping_mode, WrappingMode::NoWrapping(_)) {
|
||||||
let true_color = self.config.true_color;
|
let true_color = self.config.true_color;
|
||||||
let colored_output = self.config.colored_output;
|
let colored_output = self.config.colored_output;
|
||||||
let italics = self.config.use_italic_text;
|
let italics = self.config.use_italic_text;
|
||||||
@@ -440,8 +447,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
|
|
||||||
if text.len() != text_trimmed.len() {
|
if text.len() != text_trimmed.len() {
|
||||||
if let Some(background_color) = background_color {
|
if let Some(background_color) = background_color {
|
||||||
let mut ansi_style = Style::default();
|
let ansi_style = Style {
|
||||||
ansi_style.background = Some(to_ansi_color(background_color, true_color));
|
background: to_ansi_color(background_color, true_color),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
let width = if cursor_total <= cursor_max {
|
let width = if cursor_total <= cursor_max {
|
||||||
cursor_max - cursor_total + 1
|
cursor_max - cursor_total + 1
|
||||||
} else {
|
} else {
|
||||||
@@ -453,7 +462,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if line.bytes().next_back() != Some(b'\n') {
|
if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') {
|
||||||
writeln!(handle)?;
|
writeln!(handle)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -581,9 +590,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(background_color) = background_color {
|
if let Some(background_color) = background_color {
|
||||||
let mut ansi_style = Style::default();
|
let ansi_style = Style {
|
||||||
ansi_style.background =
|
background: to_ansi_color(background_color, self.config.true_color),
|
||||||
Some(to_ansi_color(background_color, self.config.true_color));
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
write!(
|
write!(
|
||||||
handle,
|
handle,
|
||||||
@@ -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,
|
||||||
@@ -616,19 +627,27 @@ impl Colors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn colored(theme: &Theme, true_color: bool) -> Self {
|
fn colored(theme: &Theme, true_color: bool) -> Self {
|
||||||
let gutter_color = theme
|
let gutter_style = Style {
|
||||||
.settings
|
foreground: match theme.settings.gutter_foreground {
|
||||||
.gutter_foreground
|
// If the theme provides a gutter foreground color, use it.
|
||||||
.map(|c| to_ansi_color(c, true_color))
|
// Note: It might be the special value #00000001, in which case
|
||||||
.unwrap_or(Fixed(DEFAULT_GUTTER_COLOR));
|
// to_ansi_color returns None and we use an empty Style
|
||||||
|
// (resulting in the terminal's default foreground color).
|
||||||
|
Some(c) => to_ansi_color(c, true_color),
|
||||||
|
// Otherwise, use a specific fallback color.
|
||||||
|
None => Some(Fixed(DEFAULT_GUTTER_COLOR)),
|
||||||
|
},
|
||||||
|
..Style::default()
|
||||||
|
};
|
||||||
|
|
||||||
Colors {
|
Colors {
|
||||||
grid: gutter_color.normal(),
|
grid: gutter_style,
|
||||||
|
rule: gutter_style,
|
||||||
filename: Style::new().bold(),
|
filename: Style::new().bold(),
|
||||||
git_added: Green.normal(),
|
git_added: Green.normal(),
|
||||||
git_removed: Red.normal(),
|
git_removed: Red.normal(),
|
||||||
git_modified: Yellow.normal(),
|
git_modified: Yellow.normal(),
|
||||||
line_number: gutter_color.normal(),
|
line_number: gutter_style,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ impl<'a> SyntaxMapping<'a> {
|
|||||||
MappingTarget::MapTo("Bourne Again Shell (bash)"),
|
MappingTarget::MapTo("Bourne Again Shell (bash)"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
mapping
|
||||||
|
.insert("*.pac", MappingTarget::MapTo("JavaScript (Babel)"))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// See #1008
|
// See #1008
|
||||||
mapping
|
mapping
|
||||||
@@ -54,6 +57,11 @@ impl<'a> SyntaxMapping<'a> {
|
|||||||
.insert("*.conf", MappingTarget::MapToUnknown)
|
.insert("*.conf", MappingTarget::MapToUnknown)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
// Re-insert a mapping for resolv.conf, see #1510
|
||||||
|
mapping
|
||||||
|
.insert("resolv.conf", MappingTarget::MapTo("resolv"))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
for glob in &[
|
for glob in &[
|
||||||
"/etc/nginx/**/*.conf",
|
"/etc/nginx/**/*.conf",
|
||||||
"/etc/nginx/sites-*/**/*",
|
"/etc/nginx/sites-*/**/*",
|
||||||
|
|||||||
+19
-9
@@ -3,13 +3,13 @@ use ansi_term::{self, Style};
|
|||||||
|
|
||||||
use syntect::highlighting::{self, FontStyle};
|
use syntect::highlighting::{self, FontStyle};
|
||||||
|
|
||||||
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Color {
|
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<ansi_term::Color> {
|
||||||
if color.a == 0 {
|
if color.a == 0 {
|
||||||
// Themes can specify one of the user-configurable terminal colors by
|
// Themes can specify one of the user-configurable terminal colors by
|
||||||
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
|
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
|
||||||
// to the 8-bit color palette number. The built-in themes ansi-light,
|
// to the 8-bit color palette number. The built-in themes ansi, base16,
|
||||||
// ansi-dark, base16, and base16-256 use this.
|
// and base16-256 use this.
|
||||||
match color.r {
|
Some(match color.r {
|
||||||
// For the first 8 colors, use the Color enum to produce ANSI escape
|
// For the first 8 colors, use the Color enum to produce ANSI escape
|
||||||
// sequences using codes 30-37 (foreground) and 40-47 (background).
|
// sequences using codes 30-37 (foreground) and 40-47 (background).
|
||||||
// For example, red foreground is \x1b[31m. This works on terminals
|
// For example, red foreground is \x1b[31m. This works on terminals
|
||||||
@@ -31,11 +31,18 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term:
|
|||||||
// 90-97 (foreground) and 100-107 (background), we should use those
|
// 90-97 (foreground) and 100-107 (background), we should use those
|
||||||
// for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
|
// for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
|
||||||
n => Fixed(n),
|
n => Fixed(n),
|
||||||
}
|
})
|
||||||
|
} else if color.a == 1 {
|
||||||
|
// Themes can specify the terminal's default foreground/background color
|
||||||
|
// (i.e. no escape sequence) using the encoding #RRGGBBAA with AA set to
|
||||||
|
// 01. The built-in theme ansi uses this.
|
||||||
|
None
|
||||||
} else if true_color {
|
} else if true_color {
|
||||||
RGB(color.r, color.g, color.b)
|
Some(RGB(color.r, color.g, color.b))
|
||||||
} else {
|
} else {
|
||||||
Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
|
Some(Fixed(ansi_colours::ansi256_from_rgb((
|
||||||
|
color.r, color.g, color.b,
|
||||||
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +61,10 @@ pub fn as_terminal_escaped(
|
|||||||
let mut style = if !colored {
|
let mut style = if !colored {
|
||||||
Style::default()
|
Style::default()
|
||||||
} else {
|
} else {
|
||||||
let mut color = Style::from(to_ansi_color(style.foreground, true_color));
|
let mut color = Style {
|
||||||
|
foreground: to_ansi_color(style.foreground, true_color),
|
||||||
|
..Style::default()
|
||||||
|
};
|
||||||
if style.font_style.contains(FontStyle::BOLD) {
|
if style.font_style.contains(FontStyle::BOLD) {
|
||||||
color = color.bold();
|
color = color.bold();
|
||||||
}
|
}
|
||||||
@@ -67,6 +77,6 @@ pub fn as_terminal_escaped(
|
|||||||
color
|
color
|
||||||
};
|
};
|
||||||
|
|
||||||
style.background = background_color.map(|c| to_ansi_color(c, true_color));
|
style.background = background_color.and_then(|c| to_ansi_color(c, true_color));
|
||||||
style.paint(text).to_string()
|
style.paint(text).to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,11 +1,12 @@
|
|||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum WrappingMode {
|
pub enum WrappingMode {
|
||||||
Character,
|
Character,
|
||||||
NoWrapping,
|
// The bool specifies whether wrapping has been explicitly disabled by the user via --wrap=never
|
||||||
|
NoWrapping(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WrappingMode {
|
impl Default for WrappingMode {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
WrappingMode::NoWrapping
|
WrappingMode::NoWrapping(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user