Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Source Link
Martin Vegter
  • 848
  • 81
  • 257
  • 449

zsh completion rules - remove file extension from completion result

I am trying to create simple zsh completion rules for a password manager script pass.

pass stores its passwords in directory structure, the files itself are .gpg files.

I want to complete directories and files in given path $HOME/passwords, so that directories names are simply completed, and file names are completed without .gpg extension

The following rules complete directory names correctly,

#compdef pass _pass() { _arguments '1: :->directory' case $state in directory) _directories -W $HOME/passwords ;; esac } 

but it completes filenames by their full name, ie foo.gpg.

How can I complete files without the .gpg extension ?