Live data from Hacker News

Awkward – A Node.js-based terminal emulator

github.com

1–10 of 64 posts

Re: Awkward – A Node.js-based terminal emulator

#3
This is good, but the data structures - eg arrays of arrays - don't really match the underlying data. Imagine what 'ip addr' or 'ifconfig' would look like - they output paragraphs rather than lines, so scraping lines wouldn't produce good output.

It'd be better - and FAR more work - to make an object pipeline based powershell equivalent for Nix, based on JSON. You could write cmdlets in any language that outputs JSON and do better at this project's goal of avoiding scraping.

    ps node | select pid
instead of:

    ps().find(function(line){ return line[3] === 'node' })[0]
Since the fields have keys, you avoid magic numbers and the code's easier to read.

(you could of course alias those to make 'pidof node' like Linux distros do)

The end result would be much better than Powershell, since it would use JSON and not be tied to .net languages.

Re: Awkward – A Node.js-based terminal emulator

#4
Neat hack! I like the idea. Initially when I read the title I thought it would be yet another 'make my shell behave more like my preferred language' type of project. Those while fun to code and play with aren't really useful in the long run. This though might just be useful.

Re: Awkward – A Node.js-based terminal emulator

#6
post #3

This is good, but the data structures - eg arrays of arrays - don't really match the underlying data. Imagine what 'ip addr' or 'ifconfig' would look like - they output paragraphs rather than lines, so scraping lines wouldn't produce good output. It'd be better - and FAR more work - to make an object pipeline based powershell equivalent for Nix, based on JSON. You could write cmdlets in any language that outputs JSON…

That sounds so good and better. Thank you, I will work on it.

Re: Awkward – A Node.js-based terminal emulator

#9

Neat hack! I like the idea. Initially when I read the title I thought it would be yet another 'make my shell behave more like my preferred language' type of project. Those while fun to code and play with aren't really useful in the long run. This though might just be useful.

Thank you!

Re: Awkward – A Node.js-based terminal emulator

#10
Uh...

  ps | awk 'NR>1{ print $1, $4}'
I'll give that the syntax of these shell programs take some work to understand but they're hard to beat for the purpose they serve.

If you're parsing plenty of JSON these days I find 'jq' indispensable. It's basically awk/sed for JSON.

I would just be sure to study those programs as they took quite a bit of effort to make them fast. And there are plenty of alternatives with extended syntax and features.

Best of luck.

Post reply on HN