• Do you use pass? Do you use tcsh?
  • Would you like to get completions from tcsh that are useful for pass?
  • Would you like stop having to type out manually pass -c so/many/subdirectories/and.web.sites.thataretoolong.com?
  • Do you like tab completion?

You are in the right place.

Caveats

  • pass uses a format of pass [command] [options] [args] that is kind of tough to fully replicate using complete in tcsh.
  • I’ve tried to assume what people would want to do with pass most of the time (namely, completing names of extant password entries) and made sure that works as expected for most commands and options.
  • Sometimes the completions might give options that aren’t applicable to a given command. (e.g., you can’t use the -c option for the cp command in pass, but complete might offer it to you if you try hard enough).
  • I guess this is beta… Please email me know if you find issues.
  • This page is written assuming you kind of know how pass works.
    Most of these caveats under most use cases won’t be a bother and you can just add the code below to your .cshrc

Can I include these completions in (wherever)

Yes, if you distribute a list of completions for your system or users, or a .cshrc that you share with others, etc., please feel free to add this to it.

If you’re distributing these completions to others, and you’d like me to update you when I make fixes, email me and let me know.

I’m also open to input from any tcsh users who have suggested improvements.

How do I use this?

Copy and paste the code into your .cshrc

Then … use pass show and hit tab for the magic!

Revision history

  • 1.0: Initial revision
  • 1.1: Edit to allow completion of commands, arguments, or name/path of password as the first argument, since pass will let you omit the show command. Improved suggestions for generate generate’s no-symbols arguments.

The code

# pass completions: Charles Mercadal, <mercadal+web@gmail.com>
# version: 1.1

if ($?PASSWORD_STORE_DIR) then
    set _pass_complete_directory = `echo $PASSWORD_STORE_DIR`
else
    set _pass_complete_directory = $HOME/.password-store
endif

alias _pass_complete_directories 'find $_pass_complete_directory -type d -depth 1 | awk -F/ '"'"'{print $NF}'"'"' | grep -v '"'"'^\.git$'"'"' | grep -v '"'"'^\.extensions$'"'"''
alias _pass_complete_files 'cd $_pass_complete_directory && find . -type f | cut -b3- | sed -e '"'"'s/\.gpg$//'"'"' -e '"'"'s/^.git.*//'"'"' -e '"'"'s/^.gpg-id$//'"'"''

set _pass_complete_arg_1=(init ls grep find show insert edit generate rm mv cp git help version -c --clip -q --qrcode `_pass_complete_files`)

complete pass \
        'c/--/(clip echo force in-place multiline no-symbols qrcode recursive)/' \
        'c/-/(c e f i m n q r)/' \
        'p/1/$_pass_complete_arg_1/' \
        'n/{ls,list,-r,--recursive}/`_pass_complete_directories`/' \
        'n/{show,edit,insert,add,--clip,-c,--qrcode,-q,--in-place,-i,--echo,-e,rm,--force,-f,--multiline,-m}/`_pass_complete_files`/' \
        'n/grep/x:<regular-expression>/' \
        'n/{find,search}/x:<pass-names>/' \
        'n@{generate,-n,--no-symbols}@x:<path/pass-name> <pass-length>@' \
        'n/{mv,rename}/x:<old-path> <new-path>/' \
        'n/{cp,copy}/x:<old-path> <new-path>/'