Live data from Hacker News

Colorize Your CLI

danyspin97.org

121–124 of 124 posts

Re: Colorize Your CLI

#121
post #81

Earlier quoted context omitted.

I would be happy if I never had to write a flaky text parser, for some command line tool, output again.

Then don’t, take json or some standard format with an off-the-shelf parser as stdin and write it as standard out. Then just use jq to munge data into json on one end and back out on the other.

> with an off-the-shelf parser as stdin

These only exist for well known tools. And, these usually explode if you're not careful about the characters in your filename.

Re: Colorize Your CLI

#122
post #6

I feel like we need a complete rewrite of terminal emulators/bash/whatever. It should be super easy to make a CLI with nice colors, good loading icons, etc. without having to deal with all kinds of color codes and cursor movement. When I press "enter" while a script is showing some progress bar, or resize the terminal window, it should handle it nicely like every other application. I use the command line whenever pos…

> showing some progress bar, or resize the terminal window, it should handle it nicely like every other application.

I just added SIGWINCH (resize event) handling to my console/progress bar library, https://pypi.org/project/console/ , though it currently needs to be using the whole line. I will fix that in the future.

Re: Colorize Your CLI

#123
post #121

Earlier quoted context omitted.

Then don’t, take json or some standard format with an off-the-shelf parser as stdin and write it as standard out. Then just use jq to munge data into json on one end and back out on the other.

> with an off-the-shelf parser as stdin These only exist for well known tools. And, these usually explode if you're not careful about the characters in your filename.

That’s not what I’m saying: your program expects to receive standard input in json format. And uses your favorite JSON parsing library to handle stdin. Generate stdout as JSON with the same library. Then, use jq to generate the standard input and output.

Re: Colorize Your CLI

#124
post #11

Really tempted to install starship but I also do a bunch of sensitive stuff with my terminal. Should I be worried about using this? I understand it's open source, yet still not confident.

starship looks good on paper, but the fact that all plugins are by default enabled (from what I can tell from the docs) is a no-go for me. Why do people need all that information on their prompt? I understand showing the git status, but is it really necessary to know that your battery is discharging and you're currently using node v10.12.3 and elm v1.2.3 every single time you run a command in some directory?

Starship can be quickly configured to have a select few "modules" enabled. This can be configured with `prompt_order`, documented here: https://starship.rs/config/#prompt

I, for one, like to know what version of Node will be used when I'm jumping between projects, so I can know which features are available to me at runtime.

Eventually we'd like to include an interactive configuration tool to help folks find a configuration that meets their needs.

Post reply on HN