password-store

Simple password manager using gpg and ordinary unix directories
git clone https://git.zx2c4.com/password-store
Log | Files | Refs | README | LICENSE

pass.fish-completion (5695B)


      1 # Copyright (C) 2012-2014 Dmitry Medvinsky <me@dmedvinsky.name>. All Rights Reserved.
      2 # This file is licensed under the GPLv2+. Please see COPYING for more information.
      3 
      4 set -l PROG 'pass'
      5 
      6 function __fish_pass_get_prefix
      7     if set -q PASSWORD_STORE_DIR
      8         realpath -- "$PASSWORD_STORE_DIR"
      9     else
     10         echo "$HOME/.password-store"
     11     end
     12 end
     13 
     14 function __fish_pass_needs_command
     15     [ (count (commandline -opc)) -eq 1 ]
     16 end
     17 
     18 function __fish_pass_uses_command
     19     set -l cmd (commandline -opc)
     20     if [ (count $cmd) -gt 1 ]
     21         if [ $argv[1] = $cmd[2] ]
     22             return 0
     23         end
     24     end
     25     return 1
     26 end
     27 
     28 function __fish_pass_print_gpg_keys
     29     gpg2 --list-keys | grep uid | sed 's/.*<\(.*\)>/\1/'
     30 end
     31 
     32 function __fish_pass_print
     33     set -l ext $argv[1]
     34     set -l strip $argv[2]
     35     set -l prefix (__fish_pass_get_prefix)
     36     set -l matches $prefix/**$ext
     37     printf '%s\n' $matches | sed "s#$prefix/\(.*\)$strip#\1#"
     38 end
     39 
     40 function __fish_pass_print_entry_dirs
     41     __fish_pass_print "/"
     42 end
     43 
     44 function __fish_pass_print_entries
     45     __fish_pass_print ".gpg" ".gpg"
     46 end
     47 
     48 function __fish_pass_print_entries_and_dirs
     49     __fish_pass_print_entry_dirs
     50     __fish_pass_print_entries
     51 end
     52 
     53 function __fish_pass_git_complete
     54     set -l prefix (__fish_pass_get_prefix)
     55     set -l git_cmd (commandline -opc) (commandline -ct)
     56     set -e git_cmd[1 2] # Drop "pass git".
     57     complete -C"git -C $prefix $git_cmd"
     58 end
     59 
     60 complete -c $PROG -f -n '__fish_pass_needs_command' -a help -d 'Command: show usage help'
     61 complete -c $PROG -f -n '__fish_pass_needs_command' -a version -d 'Command: show program version'
     62 
     63 complete -c $PROG -f -n '__fish_pass_needs_command' -a init -d 'Command: initialize new password storage'
     64 complete -c $PROG -f -n '__fish_pass_uses_command init' -s p -l path -d 'Assign gpg-id for specified sub folder of password store'
     65 
     66 complete -c $PROG -f -n '__fish_pass_needs_command' -a ls -d 'Command: list passwords'
     67 complete -c $PROG -f -n '__fish_pass_uses_command ls' -a "(__fish_pass_print_entry_dirs)"
     68 
     69 complete -c $PROG -f -n '__fish_pass_needs_command' -a insert -d 'Command: insert new password'
     70 complete -c $PROG -f -n '__fish_pass_uses_command insert' -s e -l echo -d 'Echo the password on console'
     71 complete -c $PROG -f -n '__fish_pass_uses_command insert' -s m -l multiline -d 'Provide multiline password entry'
     72 complete -c $PROG -f -n '__fish_pass_uses_command insert' -s f -l force -d 'Do not prompt before overwritting'
     73 complete -c $PROG -f -n '__fish_pass_uses_command insert' -a "(__fish_pass_print_entry_dirs)"
     74 
     75 complete -c $PROG -f -n '__fish_pass_needs_command' -a generate -d 'Command: generate new password'
     76 complete -c $PROG -f -n '__fish_pass_uses_command generate' -s n -l no-symbols -d 'Do not use special symbols'
     77 complete -c $PROG -f -n '__fish_pass_uses_command generate' -s c -l clip -d 'Put the password in clipboard'
     78 complete -c $PROG -f -n '__fish_pass_uses_command generate' -s f -l force -d 'Do not prompt before overwritting'
     79 complete -c $PROG -f -n '__fish_pass_uses_command generate' -s i -l in-place -d 'Replace only the first line with the generated password'
     80 complete -c $PROG -f -n '__fish_pass_uses_command generate' -a "(__fish_pass_print_entry_dirs)"
     81 
     82 complete -c $PROG -f -n '__fish_pass_needs_command' -a mv -d 'Command: rename existing password'
     83 complete -c $PROG -f -n '__fish_pass_uses_command mv' -s f -l force -d 'Force rename'
     84 complete -c $PROG -f -n '__fish_pass_uses_command mv' -a "(__fish_pass_print_entries_and_dirs)"
     85 
     86 complete -c $PROG -f -n '__fish_pass_needs_command' -a cp -d 'Command: copy existing password'
     87 complete -c $PROG -f -n '__fish_pass_uses_command cp' -s f -l force -d 'Force copy'
     88 complete -c $PROG -f -n '__fish_pass_uses_command cp' -a "(__fish_pass_print_entries_and_dirs)"
     89 
     90 complete -c $PROG -f -n '__fish_pass_needs_command' -a rm -d 'Command: remove existing password'
     91 complete -c $PROG -f -n '__fish_pass_uses_command rm' -s r -l recursive -d 'Remove password groups recursively'
     92 complete -c $PROG -f -n '__fish_pass_uses_command rm' -s f -l force -d 'Force removal'
     93 complete -c $PROG -f -n '__fish_pass_uses_command rm' -a "(__fish_pass_print_entries_and_dirs)"
     94 
     95 complete -c $PROG -f -n '__fish_pass_needs_command' -a edit -d 'Command: edit password using text editor'
     96 complete -c $PROG -f -n '__fish_pass_uses_command edit' -a "(__fish_pass_print_entries)"
     97 
     98 complete -c $PROG -f -n '__fish_pass_needs_command' -a show -d 'Command: show existing password'
     99 complete -c $PROG -f -n '__fish_pass_uses_command show' -s c -l clip -d 'Put password in clipboard'
    100 complete -c $PROG -f -n '__fish_pass_uses_command show' -a "(__fish_pass_print_entries)"
    101 # When no command is given, `show` is defaulted.
    102 complete -c $PROG -f -n '__fish_pass_needs_command' -s c -l clip -d 'Put password in clipboard'
    103 complete -c $PROG -f -n '__fish_pass_needs_command' -a "(__fish_pass_print_entries)"
    104 complete -c $PROG -f -n '__fish_pass_uses_command -c' -a "(__fish_pass_print_entries)"
    105 complete -c $PROG -f -n '__fish_pass_uses_command --clip' -a "(__fish_pass_print_entries)"
    106 
    107 complete -c $PROG -f -n '__fish_pass_needs_command' -a git -d 'Command: execute a git command'
    108 complete -c $PROG -f -n '__fish_pass_uses_command git' -a '(__fish_pass_git_complete)'
    109 complete -c $PROG -f -n '__fish_pass_needs_command' -a find -d 'Command: find a password file or directory matching pattern'
    110 complete -c $PROG -f -n '__fish_pass_needs_command' -a grep -d 'Command: search inside of decrypted password files for matching pattern'
    111 complete -c $PROG -f -n '__fish_pass_uses_command grep' -a '(begin
    112     set -l cmd (commandline -opc) (commandline -ct)
    113     set -e cmd[1 2] # Drop "pass grep".
    114     complete -C"grep $cmd"
    115 end)'