Terminal JSON viewer

Overview

fx preview

* Function eXecution

Features

  • Mouse support
  • Streaming support
  • Preserves key order
  • Preserves big numbers

Install

brew install fx
snap install fx
scoop install fx
pacman -S fx
pkg install fx
go install github.com/antonmedv/[email protected]

Or download pre-built binary.

Usage

Start the interactive viewer via:

fx data.json

Or

curl ... | fx

Type ? to see full list of key shortcuts.

Pretty print:

curl ... | fx .

Reducers

Write reducers in your favorite language: JavaScript (default), Python, or Ruby.

fx data.json '.filter(x => x.startsWith("a"))'
fx data.json '[x["age"] + i for i in range(10)]'
fx data.json 'x.to_a.map {|x| x[1]}'

Documentation

See full documentation.

Themes

Theme can be configured by setting environment variable FX_THEME from 1 to 9:

export FX_THEME=9

themes

Add your own themes in theme.go file.

License

MIT

Comments
  • MINGW64/Cmder issue on Windows?

    MINGW64/Cmder issue on Windows?

    I have just installed FX on Windows, on Cmder, using NPM. But there is some issue (an assertion failure in some C++ code?)

    [email protected] /c/home/xxx
    λ npm i fx -g
    C:\Users\fgeorges\AppData\Roaming\npm\fx -> C:\Users\fgeorges\AppData\Roaming\npm\node_modules\fx\index.js
    + [email protected]
    added 15 packages from 7 contributors in 3.567s
    
    [email protected] /c/home/xxx
    λ fx xxx.json
    MINGW64:/c/home/xxx[10072]: src\node_file.cc:1523: Assertion `(argc) == (5)' failed.
     1: 00007FF7E010ABAA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810
     2: 00007FF7E00B0C96 uv_loop_fork+80486
     3: 00007FF7E00B0D4F uv_loop_fork+80671
     4: 00007FF7E00A5E7D uv_loop_fork+35917
     5: 00007FF7E051367E v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+59870
     6: 00007FF7E0514BE0 v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+65344
     7: 00007FF7E0513B79 v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+61145
     8: 00007FF7E0513A5B v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+60859
     9: 000002C1D1850361
    
    [email protected] /c/home/xxx
    λ
    
    opened by fgeorges 16
  • Feature request: Copy result to clipboard.

    Feature request: Copy result to clipboard.

    Maybe that feature exists but It would be great if users could copy their search results or some fields to clipboard. I know about the ability to select but it now what I want

    opened by venikman 13
  • Extract sub-object in interactive mode

    Extract sub-object in interactive mode

    When sub-object is selected in interactive mode, by pressing x or Ctrl-e sub-object is printed to stdout in this form:

    $ <t2.json fx
    {
      "a": 11,
      "b": {
        "c": 33
      }
    }
    
    $ <t2.json fx # .b is interactively selected, key `x` is pressed
    {
      "path": ".b",
      "value": {
        "c": 33
      }
    }
    

    I had to do some changes around handling piped/TTY input and output and command line arguments. It should support all existing modes of use.

    This should also close #132

    Best regards!

    UPDATE: I removed anything about completely unneeded interactive mode forcing flags. PR is now only about interactive mode action for extraction of sub-object to support semi-interactive workflows discussed in the PR.

    opened by crackleware 12
  • EACCES: permission denied, on Ubuntu 18.04

    EACCES: permission denied, on Ubuntu 18.04

    Not working after installing with Snap on Ubuntu 18.04.

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID:	Ubuntu
    Description:	Ubuntu 18.04.1 LTS
    Release:	18.04
    Codename:	bionic
    
    $ ls -lah composer.json 
    -rwxrwxrwx 1 devrck devrck 4.0K Oct  8 16:12 composer.json
    
    $ fx composer.json 
    fs.js:642
      return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                     ^
    
    Error: EACCES: permission denied, open 'composer.json'
        at Error (native)
        at Object.fs.openSync (fs.js:642:18)
        at Object.fs.readFileSync (fs.js:510:33)
        at main (/snap/fx/24/lib/node_modules/fx/index.js:52:16)
        at run (/snap/fx/24/lib/node_modules/fx/index.js:80:5)
        at Object.<anonymous> (/snap/fx/24/lib/node_modules/fx/index.js:98:1)
        at Module._compile (module.js:577:32)
        at Object.Module._extensions..js (module.js:586:10)
        at Module.load (module.js:494:32)
        at tryModuleLoad (module.js:453:12)
    
    opened by devrck 12
  • Add snapcraft support for building snaps

    Add snapcraft support for building snaps

    I’ve been using fx for a while to make consumption of various APIs more palatable on the command line. I wish I’d know about it earlier, as it’s far superior to jq! :)

    This pull request enables creation of a snap package of fx. The single snap (built for many architectures) in the Snap Store will be installable on numerous popular Linux distributions with no changes. It’ll also be discoverable via the Snap Store, where releases are under your control.

    If you're willing to publish this under the fx project name, you just need to create an account and then register the fx name.

    A snap file created by snapcraft (our free software tool for building snaps) can then be released in the Snap Store with snap push --release stable *.snap. You'll want to install snapcraft (brew install snapcraft, snap install snapcraft, or apt install snapcraft) and login (snapcraft login) first, though.

    You may also want to consider using https://build.snapcraft.io/ which is a free build service, that can create armhf, amd64, i386, arm64 and other builds of fx, and push them to the store automatically. Alternatively it’s possible to integrate publishing the snap via a third party CI system such as travis or circle-ci.

    I appreciate snaps and snapcraft may be a new thing to you, so I’d be happy to answer any questions you may have.

    opened by popey 12
  • Display current path

    Display current path

    Hi,

    I use fx a lot to explore big json files and do some searches onto it. But I'd like to know "where I am" in file when on a result.

    Current path could be added at the bottom of screen.

    What do you think of that ?

    feature 
    opened by brunetton 11
  • Searching

    Searching

    This is modeled after vim's search behavior. Using this as an example:

    $ fx <(curl -s https://next.json-generator.com/api/json/get/VkCpIMn1U)
    
    1. Hit / to start/resume searching
    2. Enter strawberry as a plaintext search, and then hit <enter>
    3. You'll see 1 of 4 found: [0].favoriteFruit, and the JSON will expand to that path and put the cursor on the proper line: at that point, you can move around as normal, with the addition of n to go to the next search hit, and p to go back to the previous one.
    4. You can also use a regex: hit /, and the C-u to erase the previous search and enter /t(ue|hur)sday/i (note the regex syntax), and you'll see two hits
    5. Searching also includes the keys, ie eyeColor will find the 9 "eyeColor" keys in the example JSON

    The majority of this search functionality is in its own search module, the only changes to fx.js are:

    1. Adding an event listener box.on('focus', ...) which is how the search module tells the main screen to update

    2. Modifying the render method to optionally take a path argument, which the focus handler uses to tell render() which line to put the cursor on

    I also grouped some of the smaller functions lying around into helpers.js: walk (which I added a few optional arguments to), reduce, and the new log function are all in there. This was mostly because I needed walk in search.js. Also, that log() function doesn't do anything unless you define a log: "/tmp/some-file-name.log" entry in config.js.

    opened by brewingcode 11
  • [New] add `--indent` CLI arg; add tabs support

    [New] add `--indent` CLI arg; add tabs support

    Fixes #121

    Happy to add tests and usage examples if this is the right direction to be going.

    (Separately, i think thinks would be a lot cleaner if you used something like yargs as an arg parser, but that's out of scope for this PR)

    opened by ljharb 10
  • "{,x}" causes fx to crash

    Thanks for this really cool tool!

    $ echo '"{,x}"' | fx
    TypeError: Cannot read property 'slice' of null
        at /home/lydell/.npm-global/lib/node_modules/fx/node_modules/neo-blessed/lib/program.js:2543:35
        at Array.forEach (<anonymous>)
        at Program._attr (/home/lydell/.npm-global/lib/node_modules/fx/node_modules/neo-blessed/lib/program.js:2542:11)
        at Box.Element._parseTags (/home/lydell/.npm-global/lib/node_modules/fx/node_modules/neo-blessed/lib/widgets/element.js:498:26)
        at Box.Element.parseContent (/home/lydell/.npm-global/lib/node_modules/fx/node_modules/neo-blessed/lib/widgets/element.js:393:22)
        at Box.Element.setContent (/home/lydell/.npm-global/lib/node_modules/fx/node_modules/neo-blessed/lib/widgets/element.js:335:8)
        at render (/home/lydell/.npm-global/lib/node_modules/fx/fx.js:248:9)
        at start (/home/lydell/.npm-global/lib/node_modules/fx/fx.js:253:3)
        at main (/home/lydell/.npm-global/lib/node_modules/fx/index.js:42:20)
        at Socket.stdin.on (/home/lydell/.npm-global/lib/node_modules/fx/index.js:109:5)
    

    I'm using 3.0.2.

    opened by lydell 9
  • Doesn't work on windows

    Doesn't work on windows

    On windows (Windows 10/64 Bit) it fails with the error:

    fs.js:119
        throw err;
        ^
    
    Error: ENOENT: no such file or directory, open '/dev/tty'
        at Object.openSync (fs.js:443:3)
        at start (C:\Users\sbiedermann\.npm-global\node_modules\fx\fx.js:9:20)
        at main (C:\Users\sbiedermann\.npm-global\node_modules\fx\index.js:42:20)
        at Socket.stdin.on (C:\Users\sbiedermann\.npm-global\node_modules\fx\index.js:109:5)
        at Socket.emit (events.js:187:15)
        at endReadableNT (_stream_readable.js:1081:12)
        at process._tickCallback (internal/process/next_tick.js:63:19)
    
    opened by hardliner66 9
  • [feature request] support line-delimited JSON format

    [feature request] support line-delimited JSON format

    Streams of records are often produce as separated lines instead of an array object with opening bracket, commas and closing bracket.

    This format is Line-delimited JSON (jsonl)

    Instead of

    [
    {"record":"a"},
    {"record":"b"},
    {"record":"c"}
    ]
    

    we have

    {"record":"a"}
    {"record":"b"}
    {"record":"c"}
    

    Currently fx returns SyntaxError: Value expected (char 0).

    jq supports it.

    opened by setop 8
  • Question: how to enable interactive mode?

    Question: how to enable interactive mode?

    I just installed fx on a Mac (using brew install fx, which installed version 24.0) in combination with zsh. For some reason, commands like fx data.json just spits out the highlighted JSON to stdout, but not much else (very similar to what jq data.json does). How do I enter interactive mode?

    opened by wernerdegroot 2
  • Page Up/Down does not move the cursor

    Page Up/Down does not move the cursor

    Let's say I just ran the program and the cursor is on first line, then I press Page Down several times and it scrolls down some pages, but it doesn't move the cursor, then I press Up / Down arrow key, and I'm back on the first few lines in the first page.

    Solution: Handler for Page Up / Down keys should move the cursor up / down by the number of visible lines (a page) before changing the visible window.

    opened by ilius 2
  • Applying to node.js output doesn't work.

    Applying to node.js output doesn't work.

    When piping from a node response it seems unable to read the response as JSON

    ➜ node app.js     
    {
      to: null,
      from: '0x178eA30C5615225C97a880aB1F41BbE2a92230FC',
      transactionIndex: 0,
      gasUsed: BigNumber { _hex: '0x089cf3', _isBigNumber: true },
      blockHash: '0x97b9b9b368aa8dcda0bad769880e3a158f0e63fc0dbbc35f8b0bb93736a6e227',
      transactionHash: '0xd9176bcc54256fee295db100e7e1fbc237297d07a9c6ae0a46bd8c792d90f07e',umber: true },
      status: 1,
      type: 0,
      byzantium: true,
      events: []
    }
    
    ➜ node app.js | fx
    JSON Parse Error: invalid character 't'
    
    opened by ilyador 1
  • Ensure cursor stays in the viewport when jumping around

    Ensure cursor stays in the viewport when jumping around

    • GotoTop and GotoBottom actions will move the cursor to the first and last path respectively.
    • PageDown, PageUp, HalfPageDown, and HalfPageUp actions will clamp the cursor position between the first and last path in the viewport.

    Resolves https://github.com/antonmedv/fx/issues/215

    opened by ducaale 0
  • Command `/` : not flush ?

    Command `/` : not flush ?

    when I enter '/' for searching again, the last search command does not flush. I thought it was a bad experience, I have to delete command manual.

    It's different from vim.

    opened by Lilihx 2
Releases(24.0.0)
Owner
Anton Medvedev
SRE at Google
Anton Medvedev
Json-match - Command line util for matching values in a JSON input

json-match Match JSON input by specifying key and value > json-match -json '{\"p

Trond Boksasp 0 Jan 12, 2022
Terminal client for SimpleNote

GoNote - Terminal client for SimpleNote GoNote is a simple utility for managing notes in your SimpleNote account. It allows basic operations like crea

Konrad Wąsowicz 54 Sep 28, 2022
gomerge is a tool to quickly bulk merge several pull requests from your terminal.

Gomerge is a tool to quickly enable you to bulk merge Github pull requests from your terminal. The intention of this tool is to simplfy, and eventually automate the merging of github pull requests. This tool should be able to run on most systems.

Cian Gallagher 34 Sep 22, 2022
`tmax` is a powerful tool to help you get terminal cmd directly.

The positioning of tmax is a command line tool with a little artificial intelligence. If you frequently deal with the terminal daily, tmax will greatly improve your work efficiency.

Jeremy 31 Sep 22, 2022
YouTube client on your terminal

MeowTube YouTube client on your terminal Table of Contents About Getting Started Usage Contributing About MeowTube is a CLI (Command Line Interface) t

Abdul Fattah Ikhsan 27 Jul 29, 2022
🎄 A Christmas tree right from your terminal!

ctree ?? A Christmas tree right from your terminal! ?? Demo ⌛ No Refresh Don't want the tree to refresh every 2 seconds? Easy! Just add the --no-refre

Matthew Gleich 37 Jan 3, 2022
progress_bar creates a single customizable progress bar for Linux terminal.

progress_bar Go Progress Bar Features progress_bar creates a single customizable progress bar for Linux terminal. Installation go get -u github.com/er

erman imer 127 Aug 12, 2022
A terminal based typing test.

What A terminal based typing test. Installation Linux sudo curl -L https://github.com/lemnos/tt/releases/download/v0.4.0/tt-linux -o /usr/local/bin/tt

null 392 Sep 23, 2022
Raspberry Pi terminal based activity monitor

pitop Raspberry Pi terminal based activity monitor Yes I know there are plenty of solutions already available, but I wanted to build my own terminal b

Pierre 219 Sep 2, 2022
❓🖼 Find the anime scene by image using your terminal

What Anime CLI ❓ ?? > This application is basically a ?? wrapper around trace.moe PREVIEW Usage ?? Get Anime By Image File ?? what-anime file anime.jp

Ilya Revenko 737 Sep 23, 2022
Terminal stock ticker with live updates and position tracking

Ticker Terminal stock watcher and stock position tracker Features Live stock price quotes Track value of your stock positions Support for multiple cos

Ani Channarasappa 4.4k Sep 26, 2022
lazyhub - Terminal UI Client for GitHub using gocui.

lazyhub - Terminal UI Client for GitHub using gocui.

ryo-ma 165 Sep 27, 2022
A modern and intuitive terminal-based text editor

micro is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals

Zachary Yedidia 20.4k Oct 3, 2022
Pi-hole data right from your terminal. Live updating view, query history extraction and more!

Pi-CLI Pi-CLI is a command line program used to view data from a Pi-Hole instance directly in your terminal.

Reece Mercer 41 Apr 26, 2022
💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more ?? It's completely configurable and 100% cross-platform compatible.

null 3k Sep 23, 2022
A collection of terminal-based widgets for richer Golang CLI apps.

Flinch A collection of terminal-based widgets for richer Golang CLI apps. Ships with a library to build your own widgets/TUIs too. Warning: This modul

Liam Galvin 39 Jul 22, 2022
A wrapper around cd and xdg-open to use aliases to directory paths in terminal

CDD - Change directories Dynamically I am a lazy linux user and turns out that basic tab completion wasn't enough for me to navigate through my direct

Navdeep Singh Rathore 15 Apr 21, 2022
Terminal multiplexer inspired by i3

3mux is a terminal multiplexer with out-of-the-box support for search, mouse-controlled scrollback, and i3-like keybindings. Imagine tmux with a small

Aaron Janse 1.7k Sep 20, 2022
A simple terminal UI for Go linters

golintui golintui is a TUI tool that helps you run various kinds of linters with ease and organize its results, with the power of golangci-lint. Cool

Ryo Nakao 76 Jun 9, 2022