Command line
Every option, the formats, the keys used most, the limits, and the exit statuses, as aless --help prints them in full.
This page is the reference that aless --help prints for aless 0.8.0. aless -h prints a summary of the options. man aless prints this reference as a man page. The same text is also in the plain-text file command-line.txt, as the terminal shows it.
Usage #
aless [OPTIONS] [FILE]...- each FILE in a tab of its own
aless [OPTIONS] DIRECTORY- the directory, in the explorer
COMMAND | aless [OPTIONS]- standard input, read as JSON unless
-ksays otherwise
-h prints a summary of the options. --help prints this whole reference.
The viewer #
aless is a viewer for the terminal. Each FILE opens in a tab of its own, as a tree: you can fold the tree, search it, and copy from it. A directory opens in the explorer. With no FILE, aless reads standard input when standard input is not a terminal. Otherwise aless explores the current directory. aless watches every file: when a file changes on disk, aless reads it again and keeps your place. A file that does not parse opens as the parser's report. The report gives the line and column where the parse stopped.
aless refuses to start without a terminal to draw on and read keys from. It refuses when standard output is a pipe or a file, when there is no terminal to open, or when TERM is dumb. It refuses before reading any input. It writes one line on standard error and exits with the status 2. Only -h, --help, -V, --generate, and --print-json write to standard output. --print-json is the one option that reads an input without a terminal: it prints the input's tree as JSON, and exits.
Input options #
What is read, and how
Viewer options #
How the input is shown
Other options #
Input and formats #
FILE is a path, or - for standard input. Options end at --, so every argument after -- is a FILE, even one that starts with -. A long option's value follows it, or is attached with = (--kind=yaml).
A file's format comes from its extension, or from its whole name when that name is a --grammar NAME (/etc/hosts). -k FORMAT overrides the format for every input. Inside aless, :format FORMAT reads a tab again as FORMAT, and :open PATH FORMAT opens a file as FORMAT. A file whose extension no format claims is read as plain text: an array of its lines.
Keys keep their order in the source. A number keeps its spelling where JSON spells it the same way. So 1.0, 1e21, and an integer beyond 2^53 are shown, searched, copied, and written by :w as the source writes them. Where JSON has no syntax for a spelling, such as 0x1F, 1_000, or +1, aless reads the number as the 64-bit float that the spelling stands for. The source view (s) shows the spelling.
These are the formats, each with the extensions that imply it:
| Format | Extensions |
|---|---|
json | json geojson har jsonld webmanifest |
jsonl | jsonl ndjson |
jsonic | jsonic |
jsonc | jsonc (trailing commas accepted) |
json5 | json5 |
yaml | yaml yml |
toml | toml |
ini | ini cfg conf cnf |
csv | csv (records keyed by the header row) |
tsv | tsv tab (as csv) |
xml | xml svg xhtml xsd xsl xslt plist |
zon | zon |
markdown | md markdown (its syntax tree) |
feed | rss atom (normalised to an Atom shape) |
css | css (its syntax tree) |
proto | proto (its FileDescriptorProto, as protoc writes one in JSON) |
pgn | pgn (chess games, each its tags and moves) |
c | c h (its concrete syntax tree, every token with its place) |
abnf | abnf (the grammar spec its compiler writes, the three notations' one schema) |
ebnf | ebnf (the grammar spec its compiler writes, the three notations' one schema) |
gbnf | gbnf (the grammar spec its compiler writes, the three notations' one schema) |
expr | none, -k expr (jsonic with arithmetic, where each operation is the list of its operator and terms) |
semver | none, -k semver (a version: its major, minor, patch, prerelease, and build) |
text | txt text log (and any file no format claims) |
Keys #
The keys are those of jless. Inside aless, F1 or :help lists every key and command. These are the keys used most:
j k- Move down and up a row. A count before a key repeats it (3j).
h l- Fold and unfold, or go to the parent and the first child.
J K- Go to the next and the previous sibling.
g G- Go to the first and the last row. Ng goes to row N.
Ctrl+D Ctrl+U- Move half a page down and up.
Space- Fold or unfold the focused container.
c e- Fold and unfold the focused node and its siblings.
/ ?- Search forward and backward. The keys n and N go to the next and the previous match.
yy yp yq- Copy the value, its path, or its path as jq writes it.
m- Switch between data mode and line mode.
s- Show the source view, at the focused node's line.
!- Show the parse error report full size.
Tab Shift+Tab- Go to the next and the previous tab.
:- Start a command, such as :open PATH, :format FORMAT, :w FILE, or :help.
q- Close the tab. Closing the last tab quits. Ctrl+C quits.
Custom grammars #
--grammar NAME=FILE uses the ABNF grammar in FILE to read every file whose extension or whole name is NAME. The match ignores case. The grammar is ABNF as RFC 5234 defines it, and tabnas/abnf compiles it. -k NAME reads any input with the grammar, standard input included. Comments on a rule say what it builds: ; @object a b makes an object of its parts a and b, and ; @array makes an array. Without them, the value is the compiler's parse tree: a {"rule", "src", "kids"} node for each rule.
A grammar reads its input as plain text. In the input, the characters { } [ ] : and , are ordinary, # starts a comment that runs to the end of the line, and a word is the token TX. NR brings back numbers, ST brings back quoted strings, and VL brings back true, false, and null.
A grammar that does not compile is refused as a usage error, before any input is read. So is a repetition count over 1,024, or repetitions that would have the compiler write more than 1,024 rules. An input the grammar does not accept opens as a parse error. The input's format is the grammar's name.
The source of aless holds grammars for /etc/hosts, crontabs, /etc/passwd, /etc/group, /etc/fstab, /etc/resolv.conf, and KEY=value files. Each grammar comes with a sample. The grammars, their samples, and a guide to writing a grammar are in this directory:
https://github.com/rjrodger/aless/tree/main/tests/fixtures/grammars
Large inputs and limits #
aless reads an input whole, and parses it whole, before it shows anything. A parse runs at about 1 MB a second. It needs about 40 bytes of memory for each byte of input. The viewer waits for the parse, so aless says when it starts to read a large file. A reload of a large watched file pauses the viewer until the parse ends.
--max-size refuses an input larger than its limit before reading it. The default limit is 64M. An input over the limit opens in a tab that says so and names the size that would read it. --timeout stops a parse that runs too long. An input whose parse is stopped opens in a tab that says how far the parse got.
A document nested too deep for aless opens as a parse error with the code too_deep. Every parse stops at 3,000 open rules, about 1,000 levels. Most grammars stop sooner. JSON, JSONL, jsonic, JSON5, YAML, TOML, INI, ZON, and expressions stop at 127 levels. XML stops at 256, JSONC at 512, and CSS at 768 open rules. The braces of a .proto file can nest 100 deep. aless counts the braces before it parses the file. The Markdown tree stops at 205 levels, without an error.
C stops at an expression of about 127 operations, at 1,024 open rules, or at a syntax tree 256 levels deep. Its tree repeats subtrees, so C also stops at a tree with more than 256 values for each byte of the file, or with more than 2,048 bytes of names and strings for each byte of the file. Those limits are between 1,048,576 and 33,554,432 values, and between 8 MB and 256 MB. A grammar in ABNF, EBNF, or GBNF can nest its groups and elements 127 deep.
Exit status #
0- You quit the viewer, or
--print-jsonprinted its file's tree. 1- The viewer failed while it ran: aless could not draw on the terminal or read from it. Or
--print-jsoncould not read its file, or the file did not parse, and the report is on standard error. 2- The viewer could not start, or
--print-jsoncould not. Either there was a usage error, or there was no terminal to draw on and read keys from. A usage error is an unknown option, a bad value, or a--grammarthat does not compile or cannot be read.
Environment #
NO_COLOR- set and not empty: draw without colour, as
--no-colordoes TERM- dumb: a terminal that cannot draw the viewer, so aless refuses to start, as it does without a terminal
Files #
A release archive carries the man page and the completions. --generate prints them as well:
man/aless.1- the man page (
--generateman) completions/aless.bash- the completions for bash (
--generatecomplete-bash) completions/_aless- the completions for zsh (
--generatecomplete-zsh) completions/aless.fish- the completions for fish (
--generatecomplete-fish) completions/_aless.ps1- the completions for PowerShell (
--generatecomplete-powershell)
A shell reads its completions from where it looks for them. A package puts them there. A shell can read them from its startup file instead, each time it starts:
eval "$(aless --generate complete-bash)" # ~/.bashrc
eval "$(aless --generate complete-zsh)" # ~/.zshrc, after compinit
aless --generate complete-fish | source # config.fishExamples #
| Command | Does |
|---|---|
aless config.yaml | one file, in a tab |
aless deploy.yaml values.toml a.csv | several files, a tab each |
curl -s https://api.example/x | aless | standard input, read as JSON |
aless -k yaml settings.conf | a file whose extension misleads |
aless --grammar hosts=hosts.abnf /etc/hosts | a format of your own |
aless --no-watch big.json | no reload when the file changes |
aless -m line -n x.json | line mode, the rows numbered |
aless | explore the current directory |
See also #
jless(1)- the viewer whose keys and design aless follows
jq(1)- the tool whose path syntax the key yq copies
- the documentation
- a tutorial, how-to guides, this reference with every key, and why aless works as it does: https://aless.tabnas.dev
- the source
- the code and the releases: https://github.com/rjrodger/aless
tabnas/abnf- the ABNF compiler
--grammaruses, and its annotations: https://github.com/tabnas/abnf