fzf-tab: file-sort by access/modification time not working

Version: commit adcd317370b1dd3853d861c39fbb1b5bdb9c0568 (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).

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (18 by maintainers)

Most upvoted comments

Could you explain in more detail how to implement this?

function toggle-fzf-tab-sort() {
  if (( _no_sort_fzf_tab )); then
    zstyle ':fzf-tab:*'    extra-opts '--sort'
    zstyle ':completion:*' sort       'true'
    unset _no_sort_fzf_tab
  else
    zstyle ':fzf-tab:*'    extra-opts '--no-sort'
    zstyle ':completion:*' sort       'false'
    _no_sort_fzf_tab=1
  fi
}
zle -N toggle-fzf-tab-sort
bindkey '^T' toggle-fzf-tab-sort

Thanks. Because the fzf command is given the argument --layout=reverse, the file-sort completion needs to be reversed to get the right order:

zstyle ':completion:*' file-sort access reverse
zstyle ':completion:complete:*:argument-rest' sort false

The fzf argument --no-sort seems to be unnecessary.

Edit: Reversing the file-sort is no longer necessary.

You can set sort tag to false to let fzf-tab respect to the original order.

zstyle ':completion:complete:ls:argument-rest' sort false