Live data from Hacker News

Colorize Your CLI

danyspin97.org

61–70 of 124 posts

Re: Colorize Your CLI

#61
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?

I guess I usually know what directory I'm in and if I ever need a reminder I use pwd.

With at least 6 months of commands in ~/.bash_history

$ history | grep pwd | wc -l

      10

Re: Colorize Your CLI

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

If you do work on a number of different machines, in production and in dev, knowing what host you're on, what directory you're in, etc. helps avoid errors like killing a process in prod when you thought you were in dev.

While writing code, it's helpful to know what branch you're on with git, so you don't accidentally commit code to the wrong branch, etc.

I typically have something like 30-40 terminals open at a time, grouped into windows in tmux, so having everything categorized and visible at a glance is kind of a necessity.

Re: Colorize Your CLI

#63
post #61

Earlier quoted context omitted.

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?

I guess I usually know what directory I'm in and if I ever need a reminder I use pwd. With at least 6 months of commands in ~/.bash_history $ history | grep pwd | wc -l 10

I usually have ~20 terminal windows open, some of which have sessions opened on 4 different machines. If the host name and current working directory are not in the prompt, I need to check both every time I switch windows. Otherwise there’s no way I won’t make a mistake and do some stuff in the wrong place or on the wrong server.

I can accept that my use case is not typical, but these things are actually useful.

Re: Colorize Your CLI

#64

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.

It’s a good thing we can adapt it to our taste, then.

Re: Colorize Your CLI

#65
post #40
post #32

Earlier quoted context omitted.

I am not looking forward to using a new improved shell written in JS.

I rarely look forward to using the old, crufty shell, but I'm a madman who would like things like arrow keys and backspace and maybe even box select to actually work in a sane manner. I don't need spreadsheets and rich markup in my terminal. I just want basic HCI to work - consistently.

[deleted]

Re: Colorize Your CLI

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

> all the noise

I'm sure it takes some getting used to, if you're used to something more minimalistic, but it isn't noise to me. It's a persistent indicator of where you are, and is usually easily ignored.

The benefit of it for me is that I always have "where am I, where are files in relation to here" in the back of my mind. While switching terminals, if what's in my mind doesn't match the prompt it's really jarring and hard stops me from doing something stupid on the wrong system or directory or as the wrong user.

Re: Colorize Your CLI

#67
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?

I'm an anxious ls-er. I unconsiously ls while I'm thinking in a directory, so I usually have a pretty good sense of my location.

Re: Colorize Your CLI

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

> since my FreeBSD servers don't have a termcap file for alacritty, when I ssh into my FreeBSD servers my backspace key doesn't work (along with a lot of other things).

A hack I've got in .zshrc for this problem:

  function ssh {
   if [[ "${TERM}" = alacritty ]]; then
    env TERM=xterm-256color /usr/bin/ssh "$@"
   else
    /usr/bin/ssh "$@"
   fi
  }

Re: Colorize Your CLI

#69
post #41

Earlier quoted context omitted.

A new standard would also make it easier to fallback to no colors/decoration if the user wish so. At the moment, there is no way to do that without a flags or similar for each app. Even detecting if the terminal support colors is a pain.

> fallback to no colors/decoration if the user wish so Fallbacks are frequently not implemented, not tested or not supported as well as the main feature. > Even detecting if the terminal support colors is a pain. As the end user, I don’t mind. This means that I’ll see colors only when it’s important.

I'm with you 100%, virtually nobody will take the time to code against a fallback profile like that. That's why most sites tend not to work without JavaScript regardless of whether their functionality strictly requires it.

Support for images concern many of us for that reason: sure it seems nice for a few cases used judiciously. But it feels counter-productive to the strengths of the CLI.

I would feel that way about curses/cli-based-gui too in theory, but in practice it's just top, vim, and less for the most part. Maybe I'm just too scared.

Re: Colorize Your CLI

#70
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.

You're telling me that you don't use colors with ls? This isn't even a matter of debate, ls with colors is superior and more efficient.
Post reply on HN