Live data from Hacker News

Colorize Your CLI

danyspin97.org

81–90 of 124 posts

Re: Colorize Your CLI

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

I definitely enjoy the continuity, call me small-minded but I don’t want to see this stuff revolutionized either. Maybe because I came up in the 90s and am nostalgic for the VT220 etc, I don’t know. And it’s weird because I have little or no love for other old school stuff.

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

Re: Colorize Your CLI

#82
post #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.

Differentiating by, and extracting meaning from, color is a very ancient and important part of our visual system and every day life. Why wouldn’t you want to take advantage of it, living in a black and white world?

Re: Colorize Your CLI

#83
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,…

I have ssh sessions to remote machines, I use multiple terminal windows, and multiple tabs. I don’t use tmux, is there something about tmux that makes it hard to know where you are?

Re: Colorize Your CLI

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

Here's a snippet from my bash_aliases ...

  ### PROMPT ###
  
  function user_host_pwd() {
      printf "%c " '-'
      user -n
      printf "%c" '@'
      violet
      printf "%s" "${HOSTNAME%%.*}"
      normal
      printf "%c" ':'
      path "${PWD}"
  }
  -() { user_host_pwd ; }
  prompt_command() {
      local current="$USER@$HOSTNAME:$PWD"
      local last_cmd
      if [ "$current" == "$USER_HOSTNAME_PWD" ]; then
          last_cmd="#$(history | tail -n 1 | sed -e 's/.*[0-9]  //' | cut -d ' ' -f 1)"
          for cmd in $COMMANDS_USER_HOST_PWD_PROMPT
          do
              if [ "#${cmd}" == "$last_cmd" ]; then
                  USER_HOSTNAME_PWD=""
                  break
              fi
          done
      fi
      if [ "$current" != "$USER_HOSTNAME_PWD" ]; then
          export USER_HOSTNAME_PWD="$current"
          user_host_pwd
      fi
  }
  COMMANDS_USER_HOST_PWD_PROMPT="cd ssh sudo su login $(sed -e '/^#.*$/d' -e '/^$/d' -e 's@^.*/@@' /etc/shells | uniq | xargs)"
  PROMPT_COMMAND=prompt_command
  PS1='$ '
  [ "`id -u`" -eq 0 ] && PS1='# '

Re: Colorize Your CLI

#85
Colorizing is a red herring; it's akin to syntax highlighting: it's nice, but if you need it to determine important information then something's amiss.

I'd much prefer consistent and predictable information conveyance. Ie, I don't need Midnight Commander to be lit up like a christmas tree because I know immediately what information is displayed in its tables and panes.

Re: Colorize Your CLI

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

Why does a CLI need colours and icons? OK...colours have some value, but icons? Serious question.

Re: Colorize Your CLI

#87
post #74

Earlier quoted context omitted.

> 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 }

Installing the terminfo also works: https://github.com/alacritty/alacritty/blob/master/INSTALL.m...

Yeah, I create a .terminfo directory in my home folder on any box I ssh to and make sure it has the terminfo for the terminal I use.

Re: Colorize Your CLI

#88
post #81

Earlier quoted context omitted.

I definitely enjoy the continuity, call me small-minded but I don’t want to see this stuff revolutionized either. Maybe because I came up in the 90s and am nostalgic for the VT220 etc, I don’t know. And it’s weird because I have little or no love for other old school stuff.

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.

Re: Colorize Your CLI

#89
post #86
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…

Why does a CLI need colours and icons? OK...colours have some value, but icons? Serious question.

On a basic level, a CLI with color adds visual information that's easily seen at a glance. In this example blog post, the author shows how adding color to `df` resulted in an immediate visual distinction between mostly empty and mostly occupied space, which would normally require scanning a column to find.

Icons? It's easier to show information in a smaller area when you can use the spot a character would take with an emoji or equivalent.

Re: Colorize Your CLI

#90
post #89
post #86

Earlier quoted context omitted.

Why does a CLI need colours and icons? OK...colours have some value, but icons? Serious question.

On a basic level, a CLI with color adds visual information that's easily seen at a glance. In this example blog post, the author shows how adding color to `df` resulted in an immediate visual distinction between mostly empty and mostly occupied space, which would normally require scanning a column to find. Icons? It's easier to show information in a smaller area when you can use the spot a character would take with a…

I get that. So bold, italics and half-tone could be good enough for many/most use cases, and icons are just eye candy, right?
Post reply on HN