Live data from Hacker News

Colorize Your CLI

danyspin97.org

51–60 of 124 posts

Re: Colorize Your CLI

#51
I do like to have colorized output for my interactive CLI tools, but I will never understand a prompt other than "$" or "#".

Do people really need to continuously see all the noise like the host name, their username, the working directory, the date, or even their current branch?

Is hostname, whoami, pwd, date, git branch, and git status really to cumbersome? At least with hostname and branch I'm usually piping to pbcopy anyway.

FWIW, the -F option for ls is really nice too.

Re: Colorize Your CLI

#52
post #51

I do like to have colorized output for my interactive CLI tools, but I will never understand a prompt other than "$" or "#". Do people really need to continuously see all the noise like the host name, their username, the working directory, the date, or even their current branch? Is hostname, whoami, pwd, date, git branch, and git status really to cumbersome? At least with hostname and branch I'm usually piping to pbc…

about hostname in the prompt: if you are logged in to a bunch of server debugging a problem, it's good to see from the first sight on which system you are executing a command.

Re: Colorize Your CLI

#53

As developer I think we use too many colors everywhere. It is really necessary? Some terminals looks like a rainbow festival. A color for the user, a different color for the hostname, another one for the git branch... It is a directory? Let's add a new color. I think is too much. I like to use themes like minimal-theme [ https://github.com/anler/minimal-theme ]. My eyes appreciate it.

I agree. How about just reading the text? The human brain is excellent at quickly skimming through text and recognizing patterns. We don't need colors.

Re: Colorize Your CLI

#55
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…

Oh, please, no "color codes".

Some of us prefer a monochrome terminal, with the only distinction being bright/bold and regular text. I'm all for modernizing the classical unix tools, but turning them into kitsch Christmas trees is maybe not the best way.

Re: Colorize Your CLI

#56
post #51

I do like to have colorized output for my interactive CLI tools, but I will never understand a prompt other than "$" or "#". Do people really need to continuously see all the noise like the host name, their username, the working directory, the date, or even their current branch? Is hostname, whoami, pwd, date, git branch, and git status really to cumbersome? At least with hostname and branch I'm usually piping to pbc…

> I will never understand a prompt other than "$" or "#"

I agree with that, but some legit useful information in the prompt is the exit status of the previous command. So you may have a slightly less minimalist PS1='$?\$ ' which is typically seen as "0$" unless something went wrong. Another legit and useful information is the number of background jobs (set up to the empty string for the common case of zero jobs). Other information like the cwd, the time or the git branch are of course idiotic.

Re: Colorize Your CLI

#57
post #51

I do like to have colorized output for my interactive CLI tools, but I will never understand a prompt other than "$" or "#". Do people really need to continuously see all the noise like the host name, their username, the working directory, the date, or even their current branch? Is hostname, whoami, pwd, date, git branch, and git status really to cumbersome? At least with hostname and branch I'm usually piping to pbc…

For my local machines I don’t bother with hostname, whoami or date but the former two is essential on remote servers, so it’s good to have as defaults.

pwd is really useful since I’ve tons of terminals on tmux and typing pwd gets repetitive real quick.

Re: Colorize Your CLI

#58
post #9

Earlier quoted context omitted.

I kinda like using tooling with 40 years of refinement. Is it perfect? No. Do I need to resize a window with a progress bar? No. Would it be nice? Yeah, I guess. Am I underestimating the benefits? Almost certainly. But what are the other sharp edges that come with the shiny new thing? Would it be an electron app? Yes, probably. Would it work? Maybe, in a couple years. There would be some major bugs first, and a lot o…

There still some pretty glaring issues, even after 40 years of refinement. Some I think could be iteratively fixed but not all of them (for example I believe #1 requires a significant breaking change to terminals). 1. You can't have an interactive program in a pipeline. For example, you can't do `gpg --decrypt foo.txt.gpg | nano | gpg --encrypt` because keyboard input on the console is handled through stdin. You can…

With respect to interactive programs in a pipeline, this can already work today if the software is written to allow it. While it is common for interactive software to use the standard descriptors for I/O they are not required to. You can instead open the magic device, /dev/tty, which gets you new handles to the controlling terminal for the process.

Re: Colorize Your CLI

#59
post #9

Earlier quoted context omitted.

I kinda like using tooling with 40 years of refinement. Is it perfect? No. Do I need to resize a window with a progress bar? No. Would it be nice? Yeah, I guess. Am I underestimating the benefits? Almost certainly. But what are the other sharp edges that come with the shiny new thing? Would it be an electron app? Yes, probably. Would it work? Maybe, in a couple years. There would be some major bugs first, and a lot o…

There still some pretty glaring issues, even after 40 years of refinement. Some I think could be iteratively fixed but not all of them (for example I believe #1 requires a significant breaking change to terminals). 1. You can't have an interactive program in a pipeline. For example, you can't do `gpg --decrypt foo.txt.gpg | nano | gpg --encrypt` because keyboard input on the console is handled through stdin. You can…

> For example, you can't do `gpg --decrypt foo.txt.gpg | nano | gpg --encrypt` because keyboard input on the console is handled through stdin.

I actually had a alias at one point that did something along the lines of (IIRC):

  | editor | -> | editor -i /dev/fd/3 -o /dev/fd/4 3&1 0&2 |
Since stderr (aka &2 aka /dev/pts/whatever) is opened read-write, you can dup it onto stdin to recover the terminal. Ideally, every editor should just support reading from stdin, interacting via stderr[0], and writing to stdout as a command line option though.

Edit: 0: or /dev/tty as jclulow suggested.

Re: Colorize Your CLI

#60
post #51

I do like to have colorized output for my interactive CLI tools, but I will never understand a prompt other than "$" or "#". Do people really need to continuously see all the noise like the host name, their username, the working directory, the date, or even their current branch? Is hostname, whoami, pwd, date, git branch, and git status really to cumbersome? At least with hostname and branch I'm usually piping to pbc…

Do people really need to continuously see all the noise like .... the working directory...?

I can't imagine using a CLI prompt without knowing what directory I'm in. How would that even work?

Post reply on HN