How to customize the look of currently selected(highlighted) completion in zsh

zsh

Main question

I would like to add powerline characters at the start and at the end of the selected completion, like this:

  1. Started the completion menu by inserting c and pressing the TAB key.
  2. Moved right in the completion menu by pressing the right arrow key.
  3. Moved down in the completion menu by pressing the down arrow key.

Is there any way to make zsh look/behave like in the pictures?

Note

Added powerline triangle + blank character at the beginning and blank character + powerline triangle at the end should somehow be accounted when columns are created to keep the alignment correct.

Bonus

Add 2 blanks at the beginning of every completion in the list, so that when the completion is selected it doesn't look like the text was moved to the right.
( This issue can be seen by comparing the completion with and without the selection. )


Alternative question

In case that previously explained behavior is impossible to get without changing the zsh source code, is it at least possible to add powerline triangle only at the end of the selected completion?


My unsuccessful attempts

  • I have tried using the lc, rc, and ec variables in the list-colors style but that didn't help:
    1. Completion list was badly aligned and it created all kinds of visual problems.
    2. Symbols were inserted in all elements of the completion list, not just the selected one.
  • I have also tried using the ma variable, but I couldn't properly insert a character at the beginning:
    1. The variable expects only a number that represents a color and it is probably wrapped in some escape sequences, so the output did not look as expected.

Best Answer

This works for me.

zstyle ":completion:*:default" list-colors ${(s.:.)LS_COLORS} "ma=48;5;153;1"

Uses my LS_COLORS and then ma sets the background of my selection to bold and color 153 from https://jonasjacek.github.io/colors/.