3

I've seen things like this zsh.org thread and this Reddit thread that shows how to highlight the common prefix of the completions with a color. Unfortunately, this overrides the LS_COLORS that I've set. I derive a lot of information from my LS_COLORS and I'd like them left alone if possible. Instead, I'd rather have the common prefix notated with an underline (leaving the colors).

Like this

Like this, but with an underline instead of a color

But with an underline instead of a color, leaving my LS_COLORS intact.

EDIT:

I have a possible solution, but it requires the ability to specify different list-colors for different tags (not groups). We throw each type of file (symlink, pipe, etc.) into it's own tag, and have a group the contains them all.

PythonNut
  • 6,182
  • 1
  • 25
  • 41

1 Answers1

0

A solution with a caveat:

ls_colors_parsed=${${(@s.:.)LS_COLORS}/(#m)\**=[0-9;]#/${${MATCH/(#m)[0-9;]##/$MATCH=$MATCH=04;$MATCH}/\*/'(*files|*directories)=(#b)($PREFIX:t)(?)*'}}

function _list_colors () {
  local MATCH
  reply=("${(e@s/ /)ls_colors_parsed}")

  # fallback to a catch-all
  reply+=("=(#b)($PREFIX:t)(?)*===04")
}

zstyle -e ':completion:*:default' list-colors _list_colors

This can get slow on slow machines, and it only works for file pattern matches, not file type (directory, FIFO, etc.) matches. Those are still passed through when there is no PREFIX or PREFIX is the full match, however.

PythonNut
  • 6,182
  • 1
  • 25
  • 41