Snippet library

Save queries you run repeatedly and recall them by name in two keystrokes.

You retype the same query from memory every session, fixing typos along the way.

.users[] | select(.active == true) | {name, email} -- typed from scratch, again -- error: unexpected ")" at line 1 -- fix typo, retry -- .users[] | select(.active == true) | {name, email}

Open the library, type a few letters, press Enter. The query is applied instantly.

Press Ctrl+S Filter: act ▸ active-users .users[] | select(.active == true) | {name, email} Press Enter Snippet applied.

Apply a saved snippet

Snippet library
Press Ctrl+S to open
 
Filter: act
 
▸ active-users .users[] | select(.active == true) | {name, email}
active-emails .users[] | select(.active) | .email
 
Press Enter to apply
  1. Press Ctrl+S to open the snippet library.
  2. Type any part of the name to filter the list.
  3. Use Up / Down to highlight the one you want.
  4. Press Enter to apply it to the query input.

Save the current query

1
Ctrl+S
2
Ctrl+N
3
Name it
4
Tab
5
Enter
  1. Press Ctrl+S to open the library.
  2. Press Ctrl+N to create a new snippet.
  3. Type a short name (e.g. active-users).
  4. Press Tab — the query field is pre-filled with your current input. Edit it or leave it.
  5. Optionally Tab again to add a description.
  6. Press Enter to save.

Edit or update a snippet

To edit a snippet’s name, query, or description:

  1. Press Ctrl+S to open the library.
  2. Highlight the snippet with Up / Down.
  3. Press Ctrl+E to open the edit form.
  4. Use Tab / Shift+Tab to move between fields.
  5. Press Enter to save, or Esc to cancel.

To replace a snippet’s query with whatever is in the input right now:

  1. Open the library with Ctrl+S.
  2. Highlight the snippet.
  3. Press Ctrl+R — the snippet’s query is replaced immediately.

Delete a snippet

Open the library (Ctrl+S), highlight the snippet, press Ctrl+D.


Workflows at a glance

Browse mode
Ctrl+S Open library
Type to filter, Up/Down to navigate
 
▸ active-users .users[] | select(.active == true)
by-name-asc .users | sort_by(.name)
extract-emails [.users[].email]
 
Enter Apply Esc Close
Create mode
Ctrl+N from browse mode
 
Name: active-users
Query: .users[] | select(.active == true)
Desc: Users where .active is true
 
Tab Next field Enter Save Esc Cancel
Edit mode
Ctrl+E on selected snippet
 
Name: active-users
Query: .users[] | select(.active == true) | {name, email}
Desc: Active users with name and email
 
Tab Next field Enter Save Esc Cancel

File format

Snippets are stored as plain TOML at ~/.config/jiq/snippets.toml. You can edit it directly:

[[snippets]]
name        = "active-users"
query       = ".users[] | select(.active == true)"
description = "Users where .active is true"

[[snippets]]
name  = "by-name-asc"
query = ".users | sort_by(.name)"

All keys

Browse mode

Key Action
Ctrl+S Open or close
Up / Down Navigate the list
Type Fuzzy filter by name
Enter Apply the selected snippet
Ctrl+N Create a new snippet from current query
Ctrl+E Edit the selected snippet
Ctrl+R Replace selected snippet’s query with current input
Ctrl+D Delete the selected snippet
Esc Close

Create / edit mode

Key Action
Tab / Shift+Tab Move between fields
Enter Save
Esc Cancel