Hacker News new | ask | show | jobs
by lhnz 3627 days ago
I wonder how long it will take before something like this gets implemented as a `Hyperterm` [0] plugin.

I think it could be quite useful to combine `npm` packages with shell commands and `map`, `filter`, etc, in your terminal.

The only thing I am unsure about are the underlying representations of the shell output. Arrays of arrays are not very semantic, so the code that parses them would not be very pleasant.

Given a shape like:

  [ 
    [ 'PID', 'TTY', 'TIME', 'CMD' ],
    [ '13750', 'pts/14', '00:00:00', 'bash' ],
    [ '25193', 'pts/14', '00:00:03', 'node' ],
    [ '25283', 'pts/14', '00:00:00', 'sh' ],
    [ '25284', 'pts/14', '00:00:00', 'ps' ]
  ]
I would probably like to be able to apply some kind of transforms by default so that I can work with:

  [ 
    { pid: '13750', tty: 'pts/14', time: '00:00:00', cmd: 'bash' },
    { pid: '25193', tty: 'pts/14', time: '00:00:03', cmd: 'node' },
    { pid: '25283', tty: 'pts/14', time: '00:00:00', cmd: 'sh' },
    { pid: '25284', tty: 'pts/14', time: '00:00:00', cmd: 'ps' }
  ]
Though if this was the case you would want some way of applying the right transform depending on the arguments passed into the command.

I guess the bad thing is that there is currently presumably no way of using other shell features like pipes.

Also, if you're going to start outputting different shaped data, then I think you should consider hooking this all up to `flowtype` [1] and creating type signatures to provide DX [2]

[0] https://github.com/zeit/hyperterm

[1] https://flowtype.org/

[2] https://news.ycombinator.com/item?id=12129026