Skip to content

feature request: save preview content to file from interactive mode #405

Description

@eigl

Title: feature request: save preview content to file from interactive mode

Use case

When exploring a large JSON document interactively, I often discover a subtree I want to save to a file — but I didn't know I'd need it when I launched fx, so I didn't set up stdout redirection upfront.

This is especially common when a subtree contains a nested JSON string (e.g. an escaped JSON payload inside a string field). I want to save it to a file so I can fx it again to explore the inner structure.

Currently the options are:

  • P — prints to stdout and exits fx, requiring fx data.json > output.json to have been set up beforehand
  • y then y — copies to clipboard, which works for small values but is awkward for large subtrees (paste into a file externally)

Neither supports a "save and keep exploring" workflow.

Proposal

Add an s key binding in preview mode (p) that prompts for a file path and writes the current node's value to that file, without leaving fx.

Flow:

  1. Navigate to the desired node
  2. Press p to enter preview mode
  3. Press s — a save to: prompt appears
  4. Type a file path and press Enter
  5. See a confirmation message ("saved to output.json"), continue exploring

The s key doesn't conflict in preview mode since the "show sizes/line numbers" selector only applies in the main view.

I have a working implementation and would be happy to open a PR if this sounds useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions