Zach Riggle
Zach Riggle

Reputation: 3085

zsh completion: _arguments with _files, but only list executable files

I would like to write a ZSH completion where one of the arguments must be an executable file.

While :_files works well enough to list all files, there does not appear to be an easy way to list only executable files. The glob expression ls *(*) does this, but I'm not sure how to apply this filter to :_files.

Upvotes: 2

Views: 535

Answers (1)

Zach Riggle
Zach Riggle

Reputation: 3085

It looks like _files can take a glob expression with the -g flag.

The resulting autocomplete action then looks like :_files -g "*(*)", where (*) is the glob modifier for executable files.

Upvotes: 2

Related Questions