Skip to content
Aloxaf edited this page Oct 24, 2020 · 29 revisions

zstyle

fzf-tab use zstyle for configuration. It can give you more control over fzf-tab's behavior, eg:

# disable sort when completing options of any command
zstyle ':completion:complete:*:options' sort false

# use input as query string when completing zlua
zstyle ':fzf-tab:complete:_zlua:*' query-string input

fzf-tab is configured via command like this: zstyle ':fzf-tab:{context}' tag value. fzf-tab is the top context. My English is not good. You can see zsh's doc for more information about zstyle.

You can use C-x h to get possible context for a command:

NOTE: You need to use enable-fzf-tab to active fzf-tab again after this command.

❯ rg -- # Press `C-x h` here
tags in context :completion::complete:rg::
    operand-argument-1 options  (_arguments _rg _ripgrep)
tags in context :completion::complete:rg:options:
    options  (_arguments _rg _ripgrep)
tags in context :completion::files-enhance:::
    globbed-files  (_files _files_enhance)

Here are available tags in fzf-tab context:

fzf-command

Specify the fuzzy search program.

By default, fzf-tab use orignal fzf as the fuzzy searcher. But it also provides a wrapper named ftb-tmux-popup, which can use tmux popup (require tmux 3.2) to show results.

asciicast

You can enable it with zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup

Default value:

zstyle ':fzf-tab:*' fzf-command fzf

fzf-keybings

It can be used to add custom keybings to fzf, like zstyle ':z4h:fzf-complete' fzf-bindings 'tab:repeat' 'ctrl-a:toggle-all'

Default value: None

fzf-preview

The code for previewing.

For more information about previewing, please see Preview

fzf-flags

Any extra flags for fzf-command.

Default value: None

continuous-trigger

It specifies the key to trigger a continuous completion (accept the result and start another completion immediately). It's useful when completing a long path.

Default value: zstyle ':fzf-tab:*' continuous-trigger '/'

print-query

Press this key will use current user input as final completion result.

Default value: zstyle ':fzf-tab:*' print-query alt-enter

query-string

The strategy for generating query string.

Possible values:

  • input: use user's input as query string, just like zsh's default behavior
  • prefix: use the longest common prefix for all candidates as the query string
  • first: just a flag. If set, the first valid query string will be used
  • longest: another flag. If set, the longest valid query string will be used

Default value: zstyle ':fzf-tab:*' query-string prefix input first

prefix

A prefix to indicate the color.

Default value: zstyle ':fzf-tab:*:' prefix '·'

NOTE: If not set zstyle ':completion:*:descriptions' format, it will be set to empty.

default-color

Color when there is no group.

Default value: zstyle ':fzf-tab:*' no-group-color $'\033[37m' (white)

single-group

What to show when there is only one group.

Possible values:

  • prefix: show color prefix
  • color: show group color
  • header: show group header

Default value: zstyle ':fzf-tab:*' single-group color header

group-colors

Color for different groups and their descriptions.

Default value:

FZF_TAB_GROUP_COLORS=(
    $'\033[94m' $'\033[32m' $'\033[33m' $'\033[35m' $'\033[31m' $'\033[38;5;27m' $'\033[36m' \
    $'\033[38;5;100m' $'\033[38;5;98m' $'\033[91m' $'\033[38;5;80m' $'\033[92m' \
    $'\033[38;5;214m' $'\033[38;5;165m' $'\033[38;5;124m' $'\033[38;5;120m'
)
zstyle ':fzf-tab:*' group-colors $FZF_TAB_GROUP_COLORS

To choose the color you want, you can first use this function to print the palette:

# Usage: palette
palette() {
    local -a colors
    for i in {000..255}; do
        colors+=("%F{$i}$i%f")
    done
    print -cP $colors
}

And then use this helper function to get escape sequence for the color code:

# Usage: printc COLOR_CODE
printc() {
    local color="%F{$1}"
    echo -E ${(qqqq)${(%)color}}
}

show-group

When zstyle ':completion:*:descriptions' format is set, fzf-tab will display these group descriptions as headers.

Set to full to show all descriptions, set to brief to only show descriptions for groups with duplicate members.

Default value: zstyle ':fzf-tab:*' show-group full

Clone this wiki locally