The newest version of jless ships with a handful of new helpful features:
ys
command to copy unescaped string literals to the clipboard
p
commands, analogous to the y
commands, that print simply content to the screen. Useful for viewing long
string values, or if the clipboard functionality isn't working
C
and E
commands, analogous to the existing c
and e
commands, for deeply collapsing/expanding values
ys
will copy unescaped string literals to the
clipboard. Control characters remain escaped.
Support showing line numbers, both absolute and/or relative. Absolute line numbers refer to what line number a given node would appear on if the document were pretty printed. This means there are discontinuities when in data mode because closing brackets and braces aren't displayed. Relative line numbers show how far a line is relative to the currently focused line. The behavior of the various combinations of these settings matches vim: when using just relative line numbers alone, the focused line will show 0, but when both flags are enabled the focused line will show its absolute line number.
Absolute line numbers are enabled by default, but not relative line numbers. These
can be enabled/disabled/re-enabled via command line flags --line-numbers
,
--no-line-numbers
, --relative-line-numbers
and
--no-relative-line-numbers
, or via the short flags -n
,
-N
, -r
, and -R
respectively.
These settings can also be modified while jless is running. Entering
:set number
/:set relativenumber
will enable these settings,
:set nonumber
/:set norelativenumber
will disable them, and
:set number!
/:set relativenumber!
will toggle them, matching
vim's behavior.
There is not yet support for a jless config file, so if you would like relative
line numbers by default, it is recommended to set up an alias:
alias jless=jless --line-numbers --relative-line-numbers
.
g
or
G
. When using g
(lowercase 'g'), if the
desired line number is hidden inside of a collapsed container, the last visible
line number before the desired one will be focused. When using G
(uppercase 'G'), all the ancestors of the desired line will be expanded to
ensure it is visible.
C
and E
commands, analogous to the existing c
and e
commands, to deeply collapse/expand a node and all its siblings.
[8]
) is now inverted. Additionally, a ▶
is always
displayed next to the currently focused line, even if the focused node is a
primitive. Together these changes should make it more clear which line is
focused, especially when the terminal's current style doesn't support
dimming (ESC [ 2 m
).
c
and e
commands (and the new C
and E
commands), the focused row will stay at the same spot on the
screen. (Previously jless would try to keep the same row visible at the top of
the screen, which didn't make sense.)
ESC [ 2 K
) for each line, instead of a single "clear screen" escape
code (ESC [ 2 J
), in the hopes of reducing flicking when scrolling.
This release ships with two major new features: basic YAML support and copying to clipboard!
jless
will now check the file extension of the input file,
and automatically parse .yml
and .yaml
files as
YAML and use the same viewer as for JSON data. Alternatively passing in
the --yaml
flag will force jless
to parse the
input as YAML and can be used when reading in YAML data from stdin.
YAML aliases are automatically expanded, but their corresponding anchors
are not visible, nor are comments. YAML supports non-string keys, and
even non-scalar keys in mappings (e.g., the key of map can be an array
with multiple elements). Non-string keys are shown with square brackets,
e.g., [true]: "value"
, instead of quotes. Non-scalar keys are
handled on the screen and displayed properly, but you cannot expand and
collapse their individual elements.
While navigating data, jless also now supports copying various items to your system clipboard.
yy
will copy the value of the currently focused node,
pretty printed
yv
will copy the value of the currently focused node in a
"nicely" printed one-line format
yk
will copy the key of the current key/value pairyp
will copy the path from the root JSON element to the
currently focused node, e.g., .foo[3].bar
yb
functions like yp
, but always uses the
bracket form for object keys, e.g., ["foo"][3]["bar"]
,
which is useful if the environment where you'll paste the path doesn't
support the .key
format, like in Python
yq
will copy a jq
style path that will select the
currently focused node, e.g., .foo[].bar
ctrl-u
and ctrl-d
commands to jump up
and down by half the screen's height, or by a specified number of lines.
ctrl-b
and ctrl-f
commands for
scrolling up and down by the height of the screen. (Aliases for
PageUp
and PageDown
)
ctrl-c
or
ctrl-d
to cancel entering search input.
i
, but was undocumented;
i
has become unmapped.)
/
, ?
,
*
, #
) all now accept count arguments
Introducing jless, a command-line JSON viewer.
This release represents a significant milestone: a complete set of basic functionality, without any major bugs.
This GitHub issue details much of the functionality implemented to get to this point. Spiritually, completion of many of the tasks listed there represent versions 0.1 - 0.6.
The intention is to not release a 1.0 version until Windows support is added.