Skip to content

Combining focus and jaq

Use focusjaq to transform a subtree, or jaqfocus to explore part of a query result.

Run jaq on a record opened with focus to extract its name and duration in seconds

The subtree opened with focus becomes the input for the next jaq query. In this demo, we open the first record in the items array and extract its name and duration converted to seconds.

:focus @0 .items[0]
:jaq {name, seconds: (.duration_ms / 1000)}

The opened record becomes the root, so the query can reference .name and .duration_ms directly. Press Esc while browsing to return to the focus view showing the original subtree.

Extract failed records with jaq and open a result with focus to explore it

Select a node in the jaq results and run :focus to explore its subtree in a separate view. In this demo, we extract records whose status is failed, then open one of those records.

:jaq .items[] | select(.status == "failed")
:focus

In side-by-side mode, press Tab to switch to the result pane first. Within focus, the opened subtree becomes @0 ., and navigation and search are scoped to it. Press Esc while browsing to return to the original jaq results.

See focus and jaq for the basics of each command.