Syntax aware cat utility. Provides syntax highlighting to files printed on the command line using Tree-sitter to parse the files, and ANSI escape codes to colour them.
Syncat aims to provide similar features to the standard cat
and the similar Bat tool:
1. Git integration (-g
)
2. Show line endings (-e
)
3. Line numbering (-n
)
4. Multiple levels of framing (-f
or -ff
)
5. File concatenation
6. Parses any file type accurately using Tree-sitter
7. Customizable syntax colouring using stylesheets
In particular, the advantage of Syncat over the other options is that the parsing is done using Tree-sitter instead of with regular expressions, which makes it * very fast; * robust enough to provide useful results even in the presence of syntax errors.
Syncat does not support automatic paging, but you can just use less -r
to handle that.
Syncat can be installed from crates.io:
bash
cargo install syncat
Before you use Syncat, it must be configured.
Syncat only works once you have set up the stylesheets and languages. The quickest way to get started is to copy my personal configurations (with the advantage that you keep up to date with my changes), but this is, of course, a somewhat personal choice so you may well wish to diverge. I provide you with this option anyway:
```bash
cd ~/.config git clone https://github.com/foxfriends/config.git -b syncat syncat --recursive
cd ~/Library/Preferences/ git clone https://github.com/foxfriends/config.git -b syncat com.cameldridge.syncat --recursive ```
To configure on your own, start by creating the appropriate configuration directory, depending on
your operating system, and then continuing to the following sections. The appropriate directories
are:
* Linux: $HOME/.config/syncat/
* Mac: $HOME/Library/Preferences/com.cameldridge.syncat/
* Windows: Not officially supported
The official stylesheets (admittedly somewhat incomplete) are available here.
Stylesheets are placed in the configuration directory, under a subdirectory style
. You can
get the official themes as below, or just create this directory yourself.
bash
cd ~/.config/syncat # or `cd ~/Library/Preferences/com.cameldridge.syncat` for Mac users
git clone https://github.com/foxfriends/syncat-themes style
For full documentation on how these stylesheet customizations work, see the README in the syncat-themes repository.
As Syncat uses Tree-sitter for parsing, you must download and compile Tree-sitter parsers for Syncat to use. Fortunately, the downloading and compiling can be handled by Syncat, given you specify what to download.
The language map is a simple TOML file named languages.toml
, located in the root of the
configuration folder. A good start might be to try mine.
Each entry in this file describes one language, and is a table of 4 or 5 keys. The example entry below would install a highlighter for Syncat stylesheets.
```toml [syncat-stylesheet] # The name here is arbitrary
source = "https://github.com/foxfriends/syncat"
path = "tree-sitter-syncat-stylesheet"
source
repository into. Typicallylibrary = "syncat"
grammar.js
file from the repository.#
name = "syncat_stylesheet"
extensions = ["syncat"] ```
Once you have filled this file to your liking, the command syncat install
will install all
of those languages. Running syncat install
again later will update all languages, and install
any new ones.
```bash
syncat src/main.rs
syncat src/*.rs
syncat -l js src/package.json
languages.toml
filesyncat install
languages.toml
filesyncat install rust
languages.toml
file.languages.toml
, only deletes its installation.syncat remove rust
languages.toml
syncat list ```