fzf-tab icon indicating copy to clipboard operation
fzf-tab copied to clipboard

Improve completion descriptions

Open adelin-b opened this issue 5 years ago • 5 comments

Following #127

This add an hook to be able to enrich the description of completion Icons image image Git status image

What is left to do

  • [ ] How to set custom color ? it seem that if set in $__dscr they get escaped no matter what So I can do something like image instead of image
  • [ ] How to get the start input, git checkout <TAB> and have the string git checkout somewhere this is to match against a custom snippets file and would work a bit like bit https://github.com/chriswalz/bit but with all completion (like a real ide snippet !) image

adelin-b avatar Oct 24 '20 07:10 adelin-b

  1. This is difficult... You can reset the color, but you have no way to restore it.

  2. There is an array $words which contains the words on the command line. But it is editable so some completion function may remove some of its content...

Aloxaf avatar Oct 24 '20 16:10 Aloxaf

  1. This is difficult... You can reset the color, but you have no way to restore it.

How can I do that ? it seems that the colors are getting escaped when I try to insert some inside the completion

fzf_tab_compadd_hook() {
  # $expl - explicit group name
  # $__hits - list of orginal completions
  # $__dscr - list of transformed and described completions
  # $PREFIX - text that already got completed before

  # (grep "\b$expl" ~/.config/clisnippets)

  case $_fzf_tab_curcontext in
    # All context
    (*)
    # Line by line icon assignements
    for i in {1..$#__hits}; do
      word=$__hits[i] dscr=$__dscr[i]
      if [[ -n $dscr ]]; then
        dscr=${dscr//$'\n'}
      elif [[ -n $word ]]; then
        dscr=$word
      fi
      case "$expl" in
              (*) icon="" ;;
      esac
      icon="$icon "
      RED='\033[0;31m'
      NC='\033[0m' # No Color
      __dscr[i]="${RED}$icon $dscr"
    done
    ;;
esac
}

image

adelin-b avatar Oct 28 '20 18:10 adelin-b

How can I do that ? it seems that the colors are getting escaped when I try to insert some inside the completion

You need to use $'\033[0m'

Aloxaf avatar Oct 29 '20 00:10 Aloxaf

Hello, I saw that this wasnt merged and Im still using the modified branch, I managed to do most of what I aimed for, beside color that did not work. However I found out you rewrote it all in C.

Here is what I have at the moment on https://github.com/adelin-b/fzf-tab/tree/improve_completion_description Animation

It is on the old code so It might get me a while to move it to C. Maybe you already implemented the way to do it exposing different variable name?

adelin-b avatar May 14 '21 23:05 adelin-b

Oh sorry I haven't implement it in C. I will take a look at it in these days.

Aloxaf avatar May 17 '21 08:05 Aloxaf