A tag executable
chama _files -g '*(-*)
neste caso. Então _files
chama mais _tags
, então seria necessário especificar essas tags implicitamente especificadas nas funções de conclusão , também.
zstyle -e ':completion:*:*:-command-:*:*' tag-order '
reply=(
"executables:Executables:Executables
builtins:Builtins:Builtins
commands:Commands:Commands
aliases:Aliases:Aliases
functions:Functions:Functions
parameters:Variables:Variables
reserved-words:Keywords:Keywords
globbed-files directories"
"-"
)
'
Seria útil adicionar globbed-files
e directories
neste caso:
% ls -al
total 80
drwxr-xr-x 3 t t 4096 May 18 08:27 .
drwxrwxrwt 16 root root 69632 May 18 15:27 ..
drwxr-xr-x 2 t t 4096 May 18 08:27 directory
-rwxr-xr-x 1 t t 0 May 18 08:27 executable-file
-rw-r--r-- 1 t t 0 May 18 08:27 test
% ./<TAB>
Executables
directory/ executable-file*
Mas na configuração acima, diretórios e arquivos executáveis locais entrarão no mesmo grupo "Executável". Se gostaríamos de fazer "diretórios" entrar em outros grupos, poderíamos especificar o file-patterns
diretamente e use assim:
zstyle ':completion:*:*:-command-:*:*' file-patterns \
'*(#q-*):executables:Executables *(-/):directories:Directories'
zstyle -e ':completion:*:*:-command-:*:*' tag-order '
reply=(
"executables:Executables:Executables
builtins:Builtins:Builtins
commands:Commands:Commands
aliases:Aliases:Aliases
functions:Functions:Functions
parameters:Variables:Variables
reserved-words:Keywords:Keywords
directories:Directories"
-
)
'
No exemplo abaixo, "diretório" e "arquivo executável" estão nos grupos separados:
% ls -al
total 80
drwxr-xr-x 3 t t 4096 May 18 08:27 .
drwxrwxrwt 15 root root 69632 May 18 15:24 ..
drwxr-xr-x 2 t t 4096 May 18 08:27 directory
-rwxr-xr-x 1 t t 0 May 18 08:27 executable-file
-rw-r--r-- 1 t t 0 May 18 08:27 test
% ./<TAB>
Executables
executable-file*
Directories
directory/
Abaixo está o menor exemplo de .zshrc:
autoload -Uz compinit && compinit
zstyle ':completion:*:*:*:*:*' group-name ''
zstyle ':completion:*:descriptions' format '%B%F{black}%d%f%b'
zstyle ':completion:*:*:*:*:*' menu 'select'
# This comment out block is just for a reminder of my answer's first half.
# zstyle -e ':completion:*:*:-command-:*:*' tag-order '
# reply=(
# "executables:Executables:Executables
# builtins:Builtins:Builtins
# commands:Commands:Commands
# aliases:Aliases:Aliases
# functions:Functions:Functions
# parameters:Variables:Variables
# reserved-words:Keywords:Keywords
# globbed-files directories"
# "-"
# )
# '
zstyle ':completion:*:*:-command-:*:*' file-patterns \
'*(#q-*):executables:Executables *(-/):directories:Directories'
zstyle -e ':completion:*:*:-command-:*:*' tag-order '
reply=(
"executables:Executables:Executables
builtins:Builtins:Builtins
commands:Commands:Commands
aliases:Aliases:Aliases
functions:Functions:Functions
parameters:Variables:Variables
reserved-words:Keywords:Keywords
directories:Directories"
-
)
'
Atualizado: comente o bloqueio desnecessário.