Giter Club home page Giter Club logo

fzf-tab's Introduction

fzf-tab

CI GitHub license

Replace zsh's default completion selection menu with fzf!

asciicast

Table of Contents

Install

Important

  1. make sure fzf is installed
  2. fzf-tab needs to be loaded after compinit, but before plugins which will wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting

Manual

First, clone this repository.

git clone https://github.com/Aloxaf/fzf-tab ~/somewhere

Then add the following line to your ~/.zshrc.

autoload -U compinit; compinit
source ~/somewhere/fzf-tab.plugin.zsh

Antigen

antigen bundle Aloxaf/fzf-tab

Zinit

zinit light Aloxaf/fzf-tab

Oh-My-Zsh

Clone this repository to your custom directory and then add fzf-tab to your plugin list.

git clone https://github.com/Aloxaf/fzf-tab ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-tab

Prezto

Clone this repository to your contrib directory and then add fzf-tab to your module list in .zpreztorc.

git clone https://github.com/Aloxaf/fzf-tab $ZPREZTODIR/contrib/fzf-tab

Usage

Just press Tab as usual~

Available keybindings:

  • Ctrl+Space: select multiple results, can be configured by fzf-bindings tag

  • F1/F2: switch between groups, can be configured by switch-group tag

  • /: trigger continuous completion (useful when completing a deep path), can be configured by continuous-trigger tag

Available commands:

  • disable-fzf-tab: disable fzf-tab and fallback to compsys

  • enable-fzf-tab: enable fzf-tab

  • toggle-fzf-tab: toggle the state of fzf-tab. This is also a zle widget.

Configure

A common configuration is:

# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
# NOTE: don't use escape sequences here, fzf-tab will ignore them
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# force zsh not to show completion menu, which allows fzf-tab to capture the unambiguous prefix
zstyle ':completion:*' menu no
# preview directory's content with eza when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
# switch group using `<` and `>`
zstyle ':fzf-tab:*' switch-group '<' '>'

Tmux

If you're using tmux >= 3.2, we provide a script ftb-tmux-popup to make full use of it's "popup" feature.

zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup

BTW, you can also use this script outside the fzf-tab.

ls | ftb-tmux-popup

asciicast

For more information, please see Wiki#Configuration.

Binary module

By default, fzf-tab uses zsh-ls-colors to parse and apply ZLS_COLORS if you have set the list-colors tag.

However, it is a pure zsh script and is slow if you have too many files to colorize. fzf-tab is shipped with a binary module to speed up this process. You can build it with build-fzf-tab-module, then it will be enabled automatically.

Difference from other plugins

fzf-tab doesn't do "complete", it just shows you the results of the default completion system.

So it works EVERYWHERE (variables, function names, directory stack, in-word completion, etc.). And most of your configuration for default completion system is still valid.

Compatibility with other plugins

Some plugins may also bind "^I" to their custom widget, like fzf/shell/completion.zsh or ohmyzsh/lib/completion.zsh.

By default, fzf-tab will call the widget previously bound to "^I" to get the completion list. So there is no problem in most cases, unless fzf-tab is initialized before a plugin which doesn't handle the previous binding properly.

So if you find your fzf-tab doesn't work properly, please make sure it is the last plugin to bind "^I" (If you don't know what I mean, just put it to the end of your plugin list).

Related projects

fzf-tab's People

Contributors

aloxaf avatar atomicstack avatar avamsi avatar badouralix avatar bxsx avatar dmorgan-fa avatar doubleloop avatar druckdev avatar ecksdy avatar fluxtendu avatar frankruegamer avatar freddieoliveira avatar geodimm avatar henrebotha avatar ins0mniaque avatar jrwrigh avatar kidonng avatar mattalxndr avatar menketechnologies avatar nicholas85 avatar nightmachinery avatar qoomon avatar rcarriga avatar romkatv avatar solarizedalias avatar unavaliabl3 avatar webmastak avatar wtfzambo avatar xtorker avatar zebolino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fzf-tab's Issues

[BUG] fzf-tmux pane only partially filled with results

Describe the bug
When pressing Tab, the fzf-tmux menu only shows 8 entries. It also seems to have no effect when I export FZF_TAB_COMMAND=fzf; I still get fzf-tmux. Same with export FZF_TMUX=0. The height is correct at 40%.

Expected behavior
The results should fill the fzf-tmux split, and when I delete my custom env vars, it should revert to default behavior.

Screenshots
With the below env vars
Original settings

After running

unset FZF_TMUX_HEIGHT
unset FZF_TAB_COMMAND
unset FZF_TAB_OPTS

It looks like this (more results, but still not full. And still in a tmux split??)
Without custom settings

Environment (please complete the following information):

  • OS: Arch Linux
  • zsh version 5.8
  • fzf-tab version aa4a356
  • Output of env | rg FZF
FZF_TMUX=1
FZF_TMUX_HEIGHT=40%
FZF_TAB_COMMAND=fzf-tmux
FZF_DEFAULT_COMMAND=fd -t f -HL --color=always
FZF_DEFAULT_OPTS=--ansi --height 40%
FZF_PREVIEW_OPTS=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'
FZF_FIND_FILE_COMMAND=fd -t f -HL --color=always
FZF_FIND_FILE_OPTS=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'
FZF_OPEN_COMMAND=fd -t f -HL --color=always
FZF_OPEN_OPTS=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'
FZF_PREVIEW_FILE_CMD=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'
FZF_PREVIEW_DIR_CMD=exa -la --color=always
FZF_ENABLE_OPEN_PREVIEW=1
FZF_CD_COMMAND=fd -L -t d --color=always
FZF_CD_WITH_HIDDEN_COMMAND=fd -L -t d --color=always -H
FZF_CD_OPTS=--ansi --preview-window=right:60% --preview='exa -la --color=always {}'
FZF_CTRL_T_COMMAND=fd -t f -HL --color=always
FZF_CTRL_T_OPTS=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'
FZF_COMPLETION_OPTS=--ansi --bind='?:toggle-preview' --bind='ctrl-u:preview-page-up' --bind='ctrl-d:preview-page-down' --preview-window='right:60%:wrap' --preview='bat --color=always --style=full --line-range :300 {} 2>/dev/null || tree -C {}'

[FR] Ignore headers if only one group

Firstly, let me thank you for developing such a nice plugin!

I have following lines in my ~/.zshrc:

FZF_TAB_COMMAND=(
    fzf
    --ansi   # Enable ANSI color support, necessary for showing groups
    --expect='$continuous_trigger' # For continuous completion
    --nth=2,3 --delimiter='\x00'  # Don't search prefix
    --layout=reverse --height='${FZF_TMUX_HEIGHT:=30%}' --min-height=12
    --tiebreak=begin -m --bind=tab:down,btab:up,change:top,ctrl-space:toggle --cycle
    '--query=$query'   # $query will be expanded to query string at runtime.
    '--header-lines=$#headers' # $#headers will be expanded to lines of headers at runtime
)
zstyle ':fzf-tab:*' command $FZF_TAB_COMMAND

It would be nice to disable headers at all when there is only one group as it seems to me as a waste of space. So, in the following example there should be no line -- local directory --:
image

[BUG] "error: list of process IDs must follow --pid" when using kill command

Describe the bug

As suggested in the README, I added the following in my .zshrc:

# give a preview of commandline arguments when completing `kill`
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap

When I type kill and press Tab, the running processes appear just fine but there's an error at the bottom:

error: list of process IDs must follow --pid

Usage:

Commenting the second line

# zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap`)

removes the error.

Screenshots

  • With
# .zshrc

# give a preview of commandline arguments when completing `kill`
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap

2020-03-27_17-58-06

  • With
# .zshrc

# give a preview of commandline arguments when completing `kill`
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
#zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap

2020-03-27_18-13-49

Environment

  • OS: Arch Linux
  • zsh version: 5.8.1
  • fzf-tab version: 47ed49e

zshrc

The issue occurs without any other zstyle line apart from these two. Plugins section, just in case:

zinit light romkatv/powerlevel10k
zinit light zdharma/history-search-multi-word
zinit light skywind3000/z.lua
zinit light changyuheng/fz
zinit light Aloxaf/fzf-tab
zinit wait lucid atload'_zsh_autosuggest_start' for zsh-users/zsh-autosuggestions
zinit wait lucid atload"zicompinit; zicdreplay" blockf for zsh-users/zsh-completions
zinit wait lucid atinit"zicompinit; zicdreplay" for zdharma/fast-syntax-highlighting

fuzzy-complete:15: bad set of key/value pairs for associative array

Hi!
When completing the first argument of zplugin command when there's at least one character of it entered, then the error appears:

fuzzy-complete:15: bad set of key/value pairs for associative array

I've checked that one other command that has the subcommands completed, knife, doesn't have this problem. However one other one, rails, has the same problem, however when nothing is entered as the first arg.

Missing descriptions

To reproduce:

  1. Install zsh 5.7.1 (I haven't tried any other version).
  2. Run git clone https://github.com/Aloxaf/fzf-tab.git ~/fzf-tab.
  3. Run zsh -df.
  4. Run autoload compinit && compinit.
  5. Type grep -- and hit TAB and y.
  6. Observe descriptions for on all completion candidates:
adam% grep --
--after-context                   -- specify lines of trailing context
--basic-regexp                    -- use basic regular expression
--before-context                  -- specify lines of leading context
...
  1. Hit Ctrl-C twice and run source ~/fzf-tab/fzf-tab.zsh.
  2. Type grep -- and hit TAB.
  3. Observe the unexpected lack of descriptions:
adam% grep --
> --                                                                                  
  46/46                                                                               
> --after-context                                                                     
  --basic-regexp                                                                      
  --before-context                                                                    
...

Allow fuzzy filters before completion is invoked

Aside: I applaud your effort here. A colleague of mine and I have also been pursuing a way to make fzf-style filtering the default in our zsh setup for a while. This gets a lot of it working. Great job!


From some brief usage, it seems like a filter before completion has to be a prefix, not a fuzzy filter, but then after completion begins, fuzzy filters are allowed.

For example, if I set up some filenames like this:

cd $(mktemp -d /tmp/fzf-XXX)
touch alpha-bravo-charlie alpha-charlie-delta alpha-delta-echo bravo-charlie-delta delta-echo-foxtrot

If I type ls a<TAB> I get fuzzy filtering for the a* glob matching filenames. But if I do it fuzzy style like ls abc<TAB> I get no candidates because that's a fuzzy filter, not a prefix. Once a prefix filter is active in fzf, I can clear it and then do my fuzzy version (remove "alpha-" and replace with "abc") for example, which works.

Just wondering if others expect to be able to type their fuzzy filter first then hit TAB and have it work. If so, I'd use this constantly for accessing deeply-nested files.

In the above example, I'd love to be able to type ls abc<TAB> and have it immediately expand to the only fuzzy match, alpha-bravo-charlie.

Complete expansion is inserted to fzf prompt

_bar() {
    for i in {1..10}; do
        echo "/home/foo/folder$i/bar"
    done
}
_foo() {
    local compl=(${(f)"$(_bar)"})
    compadd $compl
}
compdef _foo foo

problem: /home/foo/folder is instantly inserted to zsh prompt. So if you type:

foo tabbar

you get:

$ foo
> /home/foo/folderbar
  0/10

probably in this case, prompt should remain empty

Candidates issue with oh-my-zsh

Hi, Thanks for the great zsh plugin! I really like it.

But I have an minor issue with oh-my-zsh. As you know, oh-my-zsh also provides completion mechanism. The screenshot is below.

image

If enabling fzf-tab, it looks like this. The group headers are listed in the candidates as well. Can they be removed for better experience? It's better to colorize the candidates for different groups IMO.

image

Add space after match

I've learned to expect a space after a successful match. This is the way it is done in the OMZ completion plugin.

Display a partial match and require a second press of tab to open fzf

Okay this is a bit hard to explain, but here goes:

For example, when you have two files with a similar beginning, lets say file1.txt and file2.txt, most tab completion implementations I've seen works like this:

$ vim directory/f<TAB>
$ vim directory/file

At this point, when tab is pressed a second time, the completion plugin is invoked. I understand that this might be a personal preference, but I just thought to throw this idea out here.

Display zstyle list-colors in matches

This plugin is really neat! 😃

One thing I cannot get to work is the way files are color coded depending on the type of "file" and its permissions when you use regular zsh completion.

I set list-colors like this:

zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} 

When disabling fzf-tab the completion looks like this:
2020-02-08-164803_644x412_scrot

Notice how the symlink has a different color. Now with fzf-tab enabled that color is not displayed:

2020-02-08-164739_644x412_scrot

Is it possible to have this functionality with fzf-tab? I have not found any option that would do something like that and I have also looked through the source code and tried to figure out if and where this color information would be provided by _fzf_tab_orig_widget but I couldn't find a place where those colors appear.

[BUG] Git completion gets deleted

Describe the bug
When I type the first path segment of a directory as an argument for a Git command, the path gets deleted from prompt.

To Reproduce
Steps to reproduce the behavior:

  1. Create a testing directory
  2. cd into that directory and initialize a Git repo with git init
  3. mkdir foo
  4. touch foo/bar
  5. Type git add foo
  6. Press Tab
  7. See error: foo gets deleted and the cursor goes back one step

This always happens when you type the exact name of the directory. If you type only part of it, you get the right completion. If you put the final slash after foo, it also works as expected.

Expected behavior
It should complete with a slash in order to allow subsequent completions.

Screenshots
I made an asciicast of the problem:
asciicast

Environment (please complete the following information):

  • OS: Void Linux
  • zsh version: zsh 5.8 (x86_64-unknown-linux-gnu)
  • fzf-tab version: f0627fe

zshrc

prompt_cmd() {
  eval "$PROMPT_COMMAND"
}

precmd_functions=(prompt_cmd)

source /usr/share/google-cloud-sdk/completion.zsh.inc
source $XDG_DATA_HOME/antigen/antigen.zsh

antigen use oh-my-zsh
antigen bundle git
antigen bundle vi-mode
antigen bundle command-not-found
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle Aloxaf/fzf-tab
antigen theme lambda
antigen apply

source /usr/share/doc/fzf/completion.zsh
source /usr/share/doc/fzf/key-bindings.zsh

_gen_fzf_default_opts() {
    local gruvbox_bg0='#282828'
    local gruvbox_bg1='#3c3836'
    local gruvbox_bg3='#665c54'
    local gruvbox_red='#cc241d'
    local gruvbox_green='#98971a'
    local gruvbox_yellow='#d79921'
    local gruvbox_blue='#458588'
    local gruvbox_purple='#b16286'
    local gruvbox_aqua='#689d6a'
    local gruvbox_gray='#a89984'
    local gruvbox_gray_alt='#928374'
    local gruvbox_red_alt='#fb4934'
    local gruvbox_green_alt='#b8bb26'
    local gruvbox_yellow_alt='#fabd2f'
    local gruvbox_blue_alt='#83a598'
    local gruvbox_purple_alt='#d3869b'
    local gruvbox_aqua_alt='#8ec07c'
    local gruvbox_orange='#d65d0e'
    local gruvbox_fg1='#ebdbb2'
    local gruvbox_fg4='#a89984'

    export FZF_DEFAULT_OPTS="
      --color=bg+:$gruvbox_bg1,bg:$gruvbox_bg0,spinner:$gruvbox_yellow,hl:$gruvbox_yellow
      --color=fg:$gruvbox_fg1,header:$gruvbox_bg3,info:$gruvbox_blue,pointer:$gruvbox_blue
      --color=marker:$gruvbox_orange,fg+:$gruvbox_fg1,prompt:$gruvbox_fg4,hl+:$gruvbox_yellow
    "

    export FZF_DEFAULT_COMMAND="rg --files --hidden --follow --glob '!.git'"
}

_gen_fzf_default_opts

[BUG] Ctrl+j can't use to select the next completion.

Hi, it's first time to use fzf-tab, it's great!!! But, I got a bug.

Describe the bug

When I echo someting to fzf, I can use and to select the entry I want. But not work for fzf-tab, but works well. Check the gif below, I firstly show works, then failed.

Ctrl ij

To Reproduce
Steps to reproduce the behavior:

  1. Type vim
  2. Press Tab
  3. Use to select entry.

Expected behavior

choose the next entry, not accep the current entry.

Details

hmank ~/c/G/dotfiles master » bindkey '^j'                       
"^J" history-substring-search-down
hmank ~/c/G/dotfiles master » bindkey '^k'
"^K" history-substring-search-up

Not sure, but the defalt vi-mode, seems to accept line, but I have remap it to history-substring-search-down.

Environment (please complete the following information):

  • OS: Manjaro
  • zsh version: zsh 5.8 (x86_64-pc-linux-gnu)
  • fzf-tab version: dc909ab

zshrc

# vim mode
bindkey -v

# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour)
bindkey '^?' backward-delete-char
bindkey '^x' backward-delete-char
bindkey '^l' vi-forward-char
bindkey '^h' vi-backward-char
bindkey '^f' vi-forward-word
bindkey '^b' vi-backward-word
bindkey '^k' history-substring-search-up
bindkey '^j' history-substring-search-down
bindkey '^d' backward-kill-word

bindkey '^ ' autosuggest-execute

# allow ctrl-a and ctrl-e to move to beginning/end of line
bindkey '^a' beginning-of-line
bindkey '^e' end-of-line
# bindkey "${terminfo[khome]}" beginning-of-line
# bindkey "${terminfo[kend]}" end-of-line
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line

bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# https://superuser.com/a/1079579/913345
# Search backwards and forwards with a pattern, -M setting mode
bindkey -M vicmd '/' history-incremental-pattern-search-backward
bindkey -M vicmd '?' history-incremental-pattern-search-forward
# set up for insert mode too
bindkey -M viins '^R' history-incremental-pattern-search-backward
# S: search
bindkey -M viins '^S' history-incremental-pattern-search-forward

# vi-mode, fzf and fzf-tab must in order:
# fzf remap ^T, ^I of vi-mode
# fzf-tab remap fzf ^T
# https://github.com/junegunn/fzf/wiki/Configuring-fuzzy-completion#caveats
source /usr/share/fzf/completion.zsh
source /usr/share/fzf/key-bindings.zsh
export FZF_COMPLETION_TRIGGER=''
bindkey '^T' fzf-completion
bindkey '^I' $fzf_default_completion

source $HOME/.zshrc.d/plugins/fzf-tab/fzf-tab.plugin.zsh
bindkey '^T' toggle-fzf-tab

[BUG] _fzf_tab__main_complete:95: permission denied

Hi! I'm just trying out fzf-tab and it seems like a great addition to Zsh!

But when I write cd dot then press tab, I get these errors:

╭─    ~ ······················································ ✔  18:40:59  
╰─ cd dot_fzf_tab__main_complete:44: command not found: _setup
_fzf_tab__main_complete:95: permission denied: 
_fzf_tab__main_complete:134: command not found: _complete
_fzf_tab__main_complete:134: command not found: _ignored
❯ cd dot

I'm currently running this on macOS Caralina, with latest zsh, fzf and fd packages installed from brew.

All Zsh plugin are managed by zinit with the following configuration:

export FZF_DEFAULT_COMMAND="fd --type f --hidden . $HOME"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --type d --hidden --exclude .git . $HOME"
zinit light Aloxaf/fzf-tab

zinit light zsh-users/zsh-completions

zinit light zdharma/fast-syntax-highlighting

ZSH_AUTOSUGGEST_STRATEGY=(history completion)
ZSH_AUTOSUGGEST_USE_ASYNC=1
#ZSH_AUTOSUGGEST_MANUAL_REBIND=1
zinit light zsh-users/zsh-autosuggestions

zinit light zdharma/zsh-diff-so-fancy

zinit ice depth=1; zinit light romkatv/powerlevel10k
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

The code above is an excerpt of my dotfiles, available at: https://github.com/kdeldycke/dotfiles/blob/master/dotfiles/.zshrc#L123-L144

Duplicate completion candidates

To reproduce:

  1. Install zsh 5.7.1 (I haven't tried any other version).
  2. Run git clone https://github.com/Aloxaf/fzf-tab.git ~/fzf-tab.
  3. Run zsh -df.
  4. Run autoload compinit && compinit.
  5. Run cd ~/fzf-tab.
  6. Type git checkout maste and hit TAB.
  7. Observe maste being completed to master.
  8. Hit Ctrl-C and run source ~/fzf-tab/fzf-tab.zsh.
  9. Type git checkout maste and hit TAB.
  10. Observe the unexpected appearance of fzf:
adam% git checkout maste
> master                                                                              
  2/2                                                                                 
> master                                                                              
  master  -- Minor cleanup (#17)                                                      

[BUG] slash isn't shown when completing cd directories with '..' and env variables

Describe the bug
When using fzf-tab and trying to complete directories with current typed path already contains .. or some env vars, fzf-tab does not show trailing slash after directory names:
image
image
But built-in completion does it:
image
image

Environment:

zshrc

command -v fzf > /dev/null || disable-fzf-tab
FZF_TAB_COMMAND=(
    fzf
    --ansi   # Enable ANSI color support, necessary for showing groups
    --expect='$continuous_trigger' # For continuous completion
    --nth=2,3 --delimiter='\x00'  # Don't search prefix
    # '--color=hl:$(( $#headers == 0 ? 108 : 255 ))'
    --layout=reverse --height='${FZF_TMUX_HEIGHT:=30%}' --min-height=12
    --tiebreak=begin -m --bind=tab:down,btab:up,change:top,ctrl-space:toggle --cycle
    '--query=$query'   # $query will be expanded to query string at runtime.
    '--header-lines=$#headers' # $#headers will be expanded to lines of headers at runtime
)
zstyle ':fzf-tab:*' command $FZF_TAB_COMMAND
zstyle ':fzf-tab:*' insert-space false

# white color is there is no group
zstyle ':fzf-tab:*' $'\033[37m'

# do not show groups if only one available
zstyle ':fzf-tab:*' single-group ''

[BUG] Groups show "%B" and "%b" instead of "[" and "]"

Describe the bug
Instead of:

[alias] [main porcelain command] [plumbing internal helper command]

fzf-tab shows:

%Balias%b %Bmain porcelain command%b %Bplumbing internal helper command%b

To Reproduce
Steps to reproduce the behavior:

  1. Type 'git st'
  2. Press Tab
  3. See error

Expected behavior
The %B and %b tokens should not be shown. [ and ] should be shown instead.

Screenshots

Screen Shot 2020-05-08 at 10 36 29 AM

Environment (please complete the following information):

  • OS: MacOS 10.15.4
  • zsh version: zsh 5.7.1 (x86_64-apple-darwin19.0)
  • fzf-tab version 607a28b

zshrc
If applicable, add a minimal zshrc to help us analyze.

[BUG] Does not work on zsh 5.1.1

Steps to reproduce the behavior:

  1. docker run -it -v fzf-tab:/fzf-tab -v fzf-bin:/usr/local/sbin zshusers/zsh:5.1.1 zsh
  2. autoload -U compinit promptinit; compinit; source /fzf-tab/fzf-tab.plugin.zsh
  3. ls tab

[BUG] Error msg "scalar parameter IN_FZF_TAB created globally in function fzf-tab-complete"

Describe the bug
Error message is displayed on the first time only. Everything else works

To Reproduce
Steps to reproduce the behavior:

  1. Type 'ssh'
  2. Press Tab
  3. See error
    fzf-tab-complete:5: scalar parameter IN_FZF_TAB created globally in function fzf-tab-complete

Expected behavior
No error msg

Environment (please complete the following information):

  • OS: Darwin
  • zsh version zsh 5.8 (x86_64-apple-darwin18.7.0)
  • fzf-tab version [e.g. https://github.com/Aloxaf/fzf-tab/commit/56adfa43b6cab964249c740302c8b57d129201f0]

zshrc
If applicable, add a minimal zshrc to help us analyze.

Can't expand `file /u/l/b`

file /u/l/b's query string is not correct, but file /usr/l/b's query string is correct.
Both's expanded result is not correct.

It seems that I should replace the whole word, not trim LBUFFER and RBUFFER and then put the result between them.

file-sort by access/modification time not working

Version: commit adcd317 (current git master)

Setup

autoload -Uz compinit
compinit
antibody bundle Aloxaf/fzf-tab
zstyle ':completion:*' file-sort access
zstyle ':fzf-tab:*' extra-opts '--no-sort'
mkdir a
mkdir c
mkdir b

Problem

Without fzf-tab the output of ls <TAB> is sorted by access time (b c a), with fzf-tab the output is sorted alphabetically (a b c).

[FR] Allow selecting multiple items

Sorry for spamming the issue tracker, this is the last one for a while I promise

FZF allows selecting multiple items using the tab key. I don't know the ins and outs of this plugin but I suspect that the tab key is captured by ZSH and not passed to FZF.

There is a conflict because most people probably expect to be able to cycle completions using the tab key, so could we maybe use ctrl-tab or ctrl-return?

Completion in a brace-expansion context does not seem correct

Hi, this project is absolutely fantastic. I'm so impressed. 😄

I'm just wondering brace expansion using fzf-tab seems not perfect.

out

As shown in the GIF above, although completion source is correct, a resulting buffer after accepting the completion is not correct.

I think correct resulting buffer will be

ls ./fzf-tab/{.gitignore

Thank you for the cool project, again.

[BUG] _fzf_tab_get_candidates:16: bad set of key/value pairs for associative array

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Type 'ls '
  2. Press Tab
  3. See error
    _fzf_tab_get_candidates:16: bad set of key/value pairs for associative array

Expected behavior
A fzf window which consists of completions shows up.

Screenshots
No screenshots can be made since the error flashes away immediately.

Environment (please complete the following information):

  • OS: WSL
  • zsh version: 5.1.1
  • fzf-tab version: 607a28b

zshrc

# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/home/caixing/.oh-my-zsh"

ZSH_THEME="agnoster-newline"

DEFAULT_USER="caixing"

plugins=(git git-extras sudo z extract colored-man-pages colorize cp fancy-ctrl-z rsync tmux zsh-autosuggestions fast-syntax-highlighting zsh-completions)

source $ZSH/oh-my-zsh.sh

source /opt/cyber/setup.bash

eval "$(fasd --init auto)"

ulimit -c unlimited

alias ll='ls -alF'
alias search='sudo apt-fast search'
alias update='sudo apt-fast update'
alias install='sudo apt-fast install'
alias upgrade='sudo apt-fast upgrade'

alias rlog='sshpass -p fd124fd124 ssh [email protected]'
alias rlog82='sshpass -p 123456 ssh [email protected]'
alias rlogqz='sshpass -p qz123qz123 ssh [email protected]'

alias make4='make -j4'
alias make5='make -j5'
alias make6='make -j6'
alias make7='make -j7'

alias lspkg='dpkg --contents'
alias refresh='source ~/.zshrc'

export RESET='\e[1;0m'
export BLACK='\e[1;30m'
export RED='\e[1;31m'
export GREEN='\e[1;32m'
export YELLOW='\e[1;33m'
export BLUE='\e[1;34m'
export MAGENTA='\e[1;35m'
export CYAN='\e[1;36m'
export WHITE='\e[1;37m'

# Set default options for fzf
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git --color=always'
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border --ansi'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

Tag specific preview and cycling

Is your feature request related to a problem? Please describe.
Im trying to define different preview specific to the type/tag of the completion, for example it can be either a command / folder / textfile / image / aliases
vim
Describe the solution you'd like
Actually Im using

zstyle ':fzf-tab:complete:*' extra-opts --preview=$extract'

  # Display Information about the command
  which ${~ctxt[hpre]}$in | grep -v "not found" 2> /dev/null;
  whatis ${~ctxt[hpre]}$in 2> /dev/null;

  # Search through man and give the description segment
 man "${~ctxt[hpre]}$in" 2> /dev/null |col -bx|awk -v S="$2" "DESCRIPTION ~ S {cap="true"; print} DESCRIPTION !~ S && /^[A-Z ]+$/ {cap="false"} DESCRIPTION !~ S && !/^[A-Z ]+$/ {if(cap == "true")print}" 2> /dev/null;

  # Display images
  tiv -h ${FZF_PREVIEW_LINES} -w ${FZF_PREVIEW_COLUMNS} ${~ctxt[hpre]}$in  2> /dev/null;

  # Display exif data
  # exiftool ${~ctxt[hpre]}$in  2> /dev/null;
  
  # Display directory
  lsd --tree --depth 2 --color=always ${~ctxt[hpre]}$in 2> /dev/null
  # exa -1 --color=always ${~ctxt[hpre]}$in 2> /dev/null;
  # du -h ${~ctxt[hpre]}$in 2> /dev/null | tail -n1

  # Display file
  bat --theme="OneHalfDark" --style=numbers,changes --color always ${~ctxt[hpre]}$in 2> /dev/null | head -n50 | grep -v "bat warning";
  '

I would like to be able to handle all kind of completion types like options / commits / users / services / diff / urls.
So the extra ops should have a way to know which kind of tag is previewed.

Hence thoses questions that are in the way:

  1. How to make preview that are aware of the current tag to display?
  2. How to make functions available inside zstyle? (I tryed to define functions just above be I couldnt use theme)
  3. How to make aliases available inside zstyle? (which g work inside a shell but not when im trying to show it during the completion preview)
  4. How would you implement a way to switch the preview mode (for example the type imageFile would have 2 preview mode: exif and terminal preview)

Here is what the code above do, im using tiv for the image display and bat for the code
fzf-tab

git diff

Ctrl J-K movement

By default FZF allows you to move around the selection menu with C-J and C-K, fzf-tab does not. Is it possible to enable this?

Error: assignment to invalid subscript range

When trying to trigger the completion with pressing TAB I get this error:

_compadd_wrapper:53: compcap_list: assignment to invalid subscript range

My system:
Kernel: 5.4.2-1-MANJARO x86_64
zsh 5.7.1

[FR] fuzzy match for the first char no need match the expected completion.

Is your feature request related to a problem? Please describe.

fzf-tab shows result different with zsh default result.

See, I use a terminal software as cheat, I alias ce to cheat -e. And I use cheat created a file vim.com, cheat -e vim.com will open and edit it. In default zsh setting, if I input ce coc, presee TAB, zsh will complete it to ce vim.coc.

The follow gif show the result I discribed:

works

But if I toggle fzf-tab, after input ce coc, press TAB, zsh will complete nothing. But if I input ce vim press TAB, zsh will show all file prefix with vim, I show it blow

cheat

Describe the solution you'd like

I expect fzf-tab show ce vim.coc after I input ce coc and press TAB.

Show identical keys nearby

Output of paired parameters nearby as in the fzf-tab-completion plugin.

I have a plugin git-flow-completion how to make fzf-tab turn off when I use git?
The second question partially resolved -> added a function in the plugin and hung in .zshrc
bindkey '^ T' fzf-tab-toggle and sent a pull request.
Of course, I would like it to be done automatically.

I have fzf-tab-completion plugin does not work on the TAB key.
But bindkey '^I' fzf_completion is not convenient.
Therefore, I prefer the fzf-tab plugin.

This is displayed in fzf-tab which is not very convenient:
here the keys are scattered
https://i.imgur.com/smXYgho.gif

This is displayed in fzf-tab-completion which is very convenient:
in the example, the keys -A --all --no-ignore-removal are located together
https://i.imgur.com/zePeHQE.gif

[FR] 补全结果排序

能否参考一下bash_history/zsh_history的输入历史,对补全结果进行排序
比如我执行git checkout TAB,我极有可能想输入的是我最近输入过的分支

nvim -t infinite loop

Describe the bug
nvim -t leads to infinite loop of
_tags:comptags:36: nesting level too deep
_tags:comptags:60: nesting level too deep
_tags:comptags:67: nesting level too deep

To Reproduce
Steps to reproduce the behavior:

  1. Type 'nvim -t '
  2. Press Tab
  3. See error

Expected behavior
tags will be in menucompletioon

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2020-04-05 at 12 47 29 AM

Environment (please complete the following information):

  • OS: macoS
  • zsh version 5.8
  • fzf-tab version [e.g. https://github.com/Aloxaf/fzf-tab/commit/56adfa43b6cab964249c740302c8b57d129201f0]

zshrc
If applicable, add a minimal zshrc to help us analyze.

Does not work if completions where added with compctl

For z.lua plugin, completions are presented with standard zsh menu instead of fzf.

z.lua uses this code for completions:

_zlua_zsh_tab_completion() {
	# tab completion
	local compl
	read -l compl
	(( $+compstate )) && compstate[insert]=menu # no expand
	reply=(${(f)"$(_zlua --complete "$compl")"})
}
compctl -U -K _zlua_zsh_tab_completion _zlua

Shift+Tab toggles result entries but Tab does not

Describe the bug
When results are shown, Tab goes down and does not toggle (fzf-tab default configuration), but Shift+Tab goes up and also toggles a result entry (fzf default).

To Reproduce
Steps to reproduce the behavior:

  1. Type 'ls'
  2. Press TabTabShift+Tab
  3. See error

Expected behavior
Either Tab should toggle and go down and Shift+Tab and go up, or Tab and Shift+Tab should just go down and up

Environment (please complete the following information):

  • OS: macOS 10.14.6
  • zsh version 5.7.1
  • fzf-tab version 00effd9

zshrc
https://github.com/levito/dotfiles/blob/master/.zshrc#L44

bad option: -c errors

After this commit adcd317, I'm getting these errors

enable-fzf-tab:functions:36: bad option: -c
enable-fzf-tab:functions:39: bad option: -c
enable-fzf-tab:functions:46: bad option: -c

press tab with error

trigger the completion with pressing TAB I get this error:

  1. Install zsh 5.7.1
  2. git clone https://github.com/Aloxaf/fzf-tab.git ~/fzf-tab
  3. source ~/fzf-tab/fzf-tab.plugin.zsh
  4. put word 'git ' & tab pressed
  5. error happened
git                                                                                      
compadd:28: number expected
compadd:28: number expected
  1. press enter and show error message
    VCS_INFO_get_cmd:6: vcs_comm: assignment to invalid subscript range

My system: OS X EICaptain

Support _approximate completer

_approximate will "hook" compadd as well.

A way to support it is to unfunction compadd when call _approximate and re-define it when call other completer/functions (_complete, _description).

[BUG] Preview for cd not working

Describe the bug
I'm trying to use your example in the README.md to preview a folder with exa when using cd.

# give a preview of directory by exa when completing cd
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always ${~ctxt[hpre]}$in'

Then I'm just seeing what exa without a path shows. (Current dir)

I also changed it to the following:

# give a preview of directory by exa when completing cd
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'echo hi${~ctxt[hpre]}$in'

Then I just see hi in the preview. So the path is just not expanded.

To Reproduce
Steps to reproduce the behavior:

  1. Type 'cd'
  2. Press Tab
  3. See error

Expected behavior
I would expect to see exa $completion_path instead of exa

Environment (please complete the following information):

  • OS: macOS 10.15.4
  • zsh version 5.8 (x86_64-apple-darwin19.3.0)
  • fzf-tab version [e.g. https://github.com/Aloxaf/fzf-tab/commit/47ed49e72161aee919eeec3491fe57ad5040ead9]

zshrc
https://github.com/jandamm/dotfiles/blob/master/zsh/init.zsh
https://github.com/jandamm/dotfiles/blob/master/zsh/after/fzf-tab.zsh

Integrate `fzf-completion` with `fzf-tab-complete`

I have configured fzf completion to be smart when suggesting files and directories, it includes hidden folders, skips ignored files, and many more:

FZF_COMPLETION_TRIGGER=''                                # ctrl-t goes to fzf whenever possible

# Default file search commands
export FZF_DEFAULT_COMMAND='fd --hidden --follow --type=f'
_fzf_compgen_path() { fd --hidden --follow --type=f }

# Default directory search commands
export FZF_ALT_C_COMMAND='fd --hidden --follow --type=d'
_fzf_compgen_dir() { fd --hidden --follow --type=d }

. /usr/share/fzf/completion.zsh                          # load fzf-completion

With the above, vim <tab> shows fzf with all the files I want to see, and cd <tab> shows fzf with all the directories I want to see, including nested files and directories.

The rest of the completion is rather broken, e.g. man <tab> or pass <tab> also show fzf with the files starting from the current directory, just like with vim <tab>.

I would like to make fzf-tab kick in when this happens, i.e. for file and directory completions keep using fzf-completion because it knows well how to select files and directories, but for all the rest of the completions I want fzf-tab-complete to be executed.

Is it possible to achieve this?

Alternatively, is it possible to teach fzf-tab which files and directories it will present me? I would be fine to stop using /usr/share/fzf/completion.zsh if fzf-tab can also be told to use fd --hidden --follow --type=f for example.

Let me know if this makes sense, and thanks! :)

No completion is inserted when the cursor is not at the end of BUFFER

To reproduce:

  1. Type gre followed by space.
  2. Move cursor one position to the left so that it ends up positioned on the space right after gre.
  3. Press TAB.
  4. Select grep in fzf that pops up.

Expected: BUFFER contains grep .

Actual: BUFFER contains gre .

Similar case where completion doesn't get inserted: (gre) (cursor after gre).

This fails a bit differently: (gr) (cursor after gr). It ends up as (grep. That is, completion gets inserted but ) disappears.

Bind to double-tab

I really like this plugin, but I'd prefer to bind it to tab-tab. Is this possible? I naively tried replacing ^I with ^I^I in the script, but that didn't work.

Any and all help greatly appreciated, and many thanks for this project!

(This is similar to #8, but perhaps simpler. Feel free to close this issue if it's too similar)

[BUG] Preview shows error.

Describe the bug
Preview shows fork/exec /usr/bin/zsh: invalid argument, even if disable preview in by adding --no-preview in FZF_TAB_OPTS.

To Reproduce
Steps to reproduce the behavior:

  1. Type 'ls '
  2. Press Tab
  3. See error

Expected behavior
The preview shows correctly or can be disabled.

Screenshots
image

Environment (please complete the following information):

  • OS:
    1. Ubuntu 20.04 Windows subsystem for Linux
    2. ubuntu 19.10
  • zsh version
    1. 5.8 (wsl)
    2. 5.7.1 (ubuntu 19.10)
  • fzf-tab version current HEAD

zshrc

export PREVIEW="$HOME/zfuncs/preview.zsh"

export FZF_TAB_OPTS=(-1 --cycle --inline-info --ansi --height 40% \
	--border --layout=reverse  --expect=/ --no-preview)

 export FZF_TAB_OPTS=(-1 --cycle --inline-info --ansi --height 40% \
	--border --layout=reverse  --expect=/ --priview '$PREVIEWE {}')

# Both two above show preview error, the preview.zsh file is my custom preview script and has the right permissions.

This is fzf opts, which works well in other situations.

export FZF_DEFAULT_OPTS="--multi --cycle --inline-info --ansi --height 100% \
   --border --layout=default --preview '$PREVIEW {}' --preview-window \
   'right:70%:wrap' $FZF_PREVIEW_KEY_BIND"

 export FZF_COMPLETION_OPTS="-1 --cycle --inline-info --ansi --height 60% \
   --border --layout=reverse --preview '$PREVIEW {}' --preview-window \
   'right:70%:wrap'  $FZF_PREVIEW_KEY_BIND"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.