Add bash completion (#84)

Co-authored-by: Paweł Marciniak <sunwire+git@gmail.com>
This commit is contained in:
Paweł Marciniak
2022-06-05 15:41:08 +01:00
committed by GitHub
parent b2082bf854
commit e6f7f1b7b3
4 changed files with 77 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
dist_bashcompletion_DATA = stenc
endif

40
bash-completion/stenc Normal file
View File

@@ -0,0 +1,40 @@
#stenc bash completion
_stenc () {
local cur prev words cword
_init_completion || return
COMPREPLY=()
case $prev in
--version )
return
;;
-f )
#list tape devices
for tape in /sys/class/scsi_tape/*;
do devs+="/dev/${tape##*/} ";
done;
COMPREPLY=($(compgen -W "$devs" -- "$cur"))
return
;;
-e | --encrypt )
COMPREPLY=($(compgen -W 'off on' -- "$cur"))
return
;;
-d | --decrypt )
COMPREPLY=($(compgen -W 'off on mixed' -- "$cur"))
return
;;
-k | --keyfile )
_filedir
return
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=($(compgen -W '-f --file -e --encrypt -d --decrypt -k --key-file -a --algorithm --allow-raw-read --no-allow-raw-read --ckod -h --help --version' -- "$cur"))
return
fi
}
complete -F _stenc stenc