pashage.fish (6633B)
1 # pashage - age-backed POSIX password manager 2 # Copyright (C) 2025 Natasha Kerensikova 3 # 4 # This program is free software; you can redistribute it and/or 5 # modify it under the terms of the GNU General Public License 6 # as published by the Free Software Foundation; either version 2 7 # of the License, or (at your option) any later version. 8 # 9 # This program is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with this program; if not, write to the Free Software 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18 # TODO: incompatible options 19 20 function __fish_pashage_any_command 21 set -l cmd (commandline -poc) 22 set -q cmd[2] && string match -vq -- '-*' $cmd[2] 23 end 24 25 function __fish_pashage_command 26 set -l cmd (commandline -poc) 27 set -q cmd[2] && contains -- $cmd[2] $argv 28 end 29 30 function __fish_pashage_opt_command 31 set -l cmd (commandline -poc) 32 not set -q cmd[2] \ 33 || string match -q -- '-*' $cmd[2] \ 34 || contains -- $cmd[2] $argv 35 end 36 37 function __fish_pashage_list_dirs 38 if set -q PASHAGE_DIR 39 set -f prefix $PASHAGE_DIR 40 else if set -q PASSAGE_DIR 41 set -f prefix $PASSAGE_DIR 42 else if set -q PASSWORD_STORE_DIR 43 set -f prefix $PASSWORD_STORE_DIR 44 else 45 set -f prefix "$HOME/.passage/store" 46 end 47 set -l result $prefix/**/ 48 set -q result[1] 49 and string sub -s (string length $prefix/x) $result 50 end 51 52 function __fish_pashage_list_entries 53 if set -q PASHAGE_DIR 54 set -f prefix $PASHAGE_DIR 55 else if set -q PASSAGE_DIR 56 set -f prefix $PASSAGE_DIR 57 else if set -q PASSWORD_STORE_DIR 58 set -f prefix $PASSWORD_STORE_DIR 59 else 60 set -f prefix "$HOME/.passage/store" 61 end 62 set -l result $prefix/**.age 63 set -q result[1] 64 and string sub -s (string length $prefix/x) -e -4 $result 65 end 66 67 # Command completion 68 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 69 -a 'copy cp' -d 'Command: Copy password' 70 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 71 -a 'delete remove rm' -d 'Command: Remove password' 72 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 73 -a 'edit' -d 'Command: Edit password' 74 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 75 -a 'find' -d 'Command: Find password by name' 76 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 77 -a 'generate gen' -d 'Command: Generate a new password' 78 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 79 -a 'git' -d 'Command: Repository actions' 80 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 81 -a 'gitconfig' -d 'Command: Repository setup' 82 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 83 -a 'grep' -d 'Command: Grep into decrypted secrets' 84 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 85 -a 'help' -d 'Command: Display help' 86 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 87 -a 'init' -d 'Command: Init recipient list' 88 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 89 -a 'insert' -d 'Command: Insert existing secret' 90 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 91 -a 'list ls' -d 'Command: List passwords' 92 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 93 -a 'move mv' -d 'Command: Move password' 94 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 95 -a 'random' -d 'Command: Generate password without storage' 96 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 97 -a 're-encrypt reencrypt' -d 'Command: Re-encrypt passwords' 98 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 99 -a 'show' -d 'Command: Show a password' 100 complete -f -c pashage -n 'not __fish_pashage_any_command' \ 101 -a 'version' -d 'Command: Display version' 102 103 # Option completion 104 complete -f -c pashage -n '__fish_pashage_opt_command gen generate show' \ 105 -s 'c' -l 'clip' -d 'paste secret into clipboard' 106 complete -f -c pashage -n '__fish_pashage_command re-encrypt reencrypt' \ 107 -s 'd' -l 'deep' -d 're-encrypt subfolders with their own recipients' 108 complete -f -c pashage -n '__fish_pashage_command insert' \ 109 -s 'e' -l 'echo' -d 'non-hidden password entry' 110 complete -f -c pashage -n '__fish_pashage_command copy cp move mv' \ 111 -s 'e' -l 'reencrypt' -d 'always re-encrypt secrets' 112 complete -f -c pashage -n '__fish_pashage_command copy cp move mv' \ 113 -s 'f' -l 'force' -d 'overwrite existing secrets without confirmation' 114 complete -f -c pashage -n '__fish_pashage_command delete remove rm' \ 115 -s 'f' -l 'force' -d 'delete without asking for confirmation' 116 complete -f -c pashage -n '__fish_pashage_command gen generate insert' \ 117 -s 'f' -l 'force' -d 'replace secret without confirmation' 118 complete -f -c pashage -n '__fish_pashage_command gen generate' \ 119 -s 'i' -l 'in-place' -d 'replace first line of existing secret' 120 complete -f -c pashage \ 121 -n '__fish_pashage_command copy cp init move mv re-encrypt reencrypt' \ 122 -s 'i' -l 'interactive' -d 'ask whether to re-encrypt or not' 123 complete -f -c pashage -n '__fish_pashage_command copy cp init move mv' \ 124 -s 'k' -l 'keep' -d 'never re-encrypt secrets' 125 complete -f -c pashage -n '__fish_pashage_command gen generate' \ 126 -s 'm' -l 'multiline' -d 'append extra lines after generated secret' 127 complete -f -c pashage -n '__fish_pashage_command insert' \ 128 -s 'm' -l 'multiline' -d 'import multiple lines per secret' 129 complete -f -c pashage -n '__fish_pashage_command init' \ 130 -s 'p' -l 'path' -r -a '(__fish_pashage_list_dirs)' \ 131 -d 'initialize subfolder' 132 complete -f -c pashage -n '__fish_pashage_opt_command gen generate show' \ 133 -s 'q' -l 'qrcode' -d 'display secret as QR-code' 134 complete -f -c pashage -n '__fish_pashage_command delete remove rm' \ 135 -s 'r' -l 'recursive' -d 'recursively delete subfolders' 136 complete -f -c pashage -n '__fish_pashage_opt_command list ls find' \ 137 -s 'r' -l 'raw' -d 'raw list output' 138 complete -f -c pashage -n '__fish_pashage_command gen generate' \ 139 -s 't' -l 'try' -d 'ask confirmation before storing new password' 140 141 # Secret completion 142 complete -f -c pashage -n '__fish_pashage_command insert list ls' \ 143 -a '(__fish_pashage_list_dirs)' -d 'Subfolder' 144 complete -f -c pashage \ 145 -n '__fish_pashage_opt_command copy cp delete edit gen generate move mv re-encrypt reencrypt remve rm show' \ 146 -a '(__fish_pashage_list_entries)' -d 'Secret'