1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # bash-completion for tarsnap-recrypt
- #
- # Copyright (c) 2015-2025 Tarsnap Backup Inc.
- # Copyright (c) 2009-2012 Andreas Olsson
- #
- # Permission is hereby granted, free of charge, to any person
- # obtaining a copy of this software and associated documentation
- # files (the "Software"), to deal in the Software without
- # restriction, including without limitation the rights to use,
- # copy, modify, merge, publish, distribute, sublicense, and/or sell
- # copies of the Software, and to permit persons to whom the
- # Software is furnished to do so, subject to the following
- # conditions:
- #
- # The above copyright notice and this permission notice shall be
- # included in all copies or substantial portions of the Software.
- #
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- # OTHER DEALINGS IN THE SOFTWARE.
- shopt -s extglob
- _tarsnap_recrypt ()
- {
- local cur prev wfilearg wpatharg longopts
- COMPREPLAY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
- # These options will be completed by the path to a filename.
- wfilearg="--oldkey|--newkey"
- # These options will be completed by the path to a directory.
- wpatharg="--oldcachedir|--newcachedir"
- longopts="--oldkey --newkey --oldcachedir --newcachedir --version"
- case "$prev" in
- @($wfilearg))
- _filedir
- return 0
- ;;
- @($wpatharg))
- _filedir -d
- return 0
- ;;
- esac
- if [[ ${cur} == -* ]]
- then
- COMPREPLY=( $(compgen -W "${longopts}" -- ${cur}) )
- return 0
- fi
- }
- complete -F _tarsnap_recrypt -o filenames tarsnap-recrypt
|