From f8f80bc3918fab17f72710f9d48f32850d82d474 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 5 May 2023 10:28:15 +0100 Subject: [PATCH] Add a bash_completion script Add a script that can be source by a shell to do bash completion. Signed-off-by: David Howells --- bash_complete | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bash_complete diff --git a/bash_complete b/bash_complete new file mode 100644 index 0000000..dd01383 --- /dev/null +++ b/bash_complete @@ -0,0 +1,24 @@ +# -*- sh -*- +# bash completion script for AFS tools +# +# To use these routines: +# +# 1. Copy this file to somewhere (e.g. ~/.kafs-completion.bash). +# +# 2. Add the following line to your .bashrc: +# . ~/.kafs-completion.bash + +_afs () { + COMPREPLY=($(kafs --complete $COMP_CWORD "${COMP_WORDS[@]}")) + + case "${COMPREPLY[0]}" in + @HOSTNAME@) + COMPREPLY=($(compgen -A hostname -- "${COMP_WORDS[$COMP_CWORD]}")) + ;; + @VOLNAME@|@PARTID@|@FILE@|@OTHER@) + COMPREPLY=($(compgen -A file -- "${COMP_WORDS[$COMP_CWORD]}")) + ;; + esac +} + +complete -o bashdefault -o default -F _afs afs bos pts vos -- 2.50.1