| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
#? NAME |
| 4 |
#? bash_completion_o-saft - bash completion function for o-saft, o-saft.pl, o-saft.tcl |
| 5 |
#? |
| 6 |
#? DESCRIPTION |
| 7 |
#? This bash function provides values to be used in bash's completion |
| 8 |
#? (see bash's [TAB][TAB] key). |
| 9 |
#? |
| 10 |
#? USAGE |
| 11 |
#? source bash_completion_o-saft |
| 12 |
#? |
| 13 |
#? SEE ALSO |
| 14 |
#? bind -p | grep complete |
| 15 |
#? http://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion |
| 16 |
#? |
| 17 |
#? AUTHOR |
| 18 |
#? 14-dec-14 Achim Hoffmann |
| 19 |
# ------------------------------------------------------------------------------ |
| 20 |
|
| 21 |
# bash is not my favorite, I guess this could be improved in many ways :-) |
| 22 |
|
| 23 |
_y_cmds=`o-saft.pl --help=commands|awk '/^\+/{print $1}'` |
| 24 |
_y_opts=`o-saft.pl --help=opts |awk '/^\-/{print $1}'` |
| 25 |
_y_rang=`o-saft.pl --help=range |awk "/ *'/"'{print "--cipherrange="$1}'` |
| 26 |
_y_gui=`o-saft.tcl --help=opts |awk '/^[+-]/{print $1}'` |
| 27 |
_m_help=`make e-ALL.help |tr -s ' ' '\\012'` |
| 28 |
_m_test=`make e-ALL.tests |tr -s ' ' '\\012'` |
| 29 |
_m_warn=`make e-ALL.tests |tr -s ' ' '\\012'` |
| 30 |
|
| 31 |
_o-saft() |
| 32 |
{ |
| 33 |
local curr_arg; |
| 34 |
curr_arg=${COMP_WORDS[COMP_CWORD]} |
| 35 |
case "$curr_arg" in |
| 36 |
+*) COMPREPLY=( $(compgen -W "$_y_cmds" -- $curr_arg ) ); ;; |
| 37 |
--cipherrange*) COMPREPLY=( $(compgen -W "$_y_rang" -- $curr_arg ) ); ;; |
| 38 |
-*) COMPREPLY=( $(compgen -W "$_y_opts" -- $curr_arg ) ); ;; |
| 39 |
esac |
| 40 |
} |
| 41 |
|
| 42 |
_o-gui() |
| 43 |
{ |
| 44 |
local curr_arg; |
| 45 |
curr_arg=${COMP_WORDS[COMP_CWORD]} |
| 46 |
COMPREPLY=( $(compgen -W "$_y_gui" -- $curr_arg ) ) |
| 47 |
} |
| 48 |
|
| 49 |
_o-make() |
| 50 |
{ |
| 51 |
local curr_arg; |
| 52 |
curr_arg=${COMP_WORDS[COMP_CWORD]} |
| 53 |
case "$curr_arg" in |
| 54 |
help*) COMPREPLY=( $(compgen -W "$_m_help" -- $curr_arg ) ); ;; |
| 55 |
test*) COMPREPLY=( $(compgen -W "$_m_test" -- $curr_arg ) ); ;; |
| 56 |
warn*) COMPREPLY=( $(compgen -W "$_m_warn" -- $curr_arg ) ); ;; |
| 57 |
esac |
| 58 |
} |
| 59 |
|
| 60 |
complete -F _o-saft o-saft |
| 61 |
complete -F _o-saft o-saft.pl |
| 62 |
complete -F _o-gui o-saft.tcl |
| 63 |
complete -F _o-make make |