1 # bash programmable completion for bitcoin-tx(1)
2 # Copyright (c) 2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 local cur prev words=() cword
10 # save and use original argument to invoke bitcoin-tx for -help
11 # it might not be in $PATH
15 _get_comp_words_by_ref -n =: cur prev words cword
23 *=*) # prevent attempts to complete other arguments
28 if [[ "$cword" == 1 || ( "$prev" != "-create" && "$prev" == -* ) ]]; then
29 # only options (or an uncompletable hex-string) allowed
30 # parse bitcoin-tx -help for options
32 helpopts=$($bitcoin_tx -help | sed -e '/^ -/ p' -e d )
33 COMPREPLY=( $( compgen -W "$helpopts" -- "$cur" ) )
35 # only commands are allowed
36 # parse -help for commands
38 helpcmds=$($bitcoin_tx -help | sed -e '1,/Commands:/d' -e 's/=.*/=/' -e '/^ [a-z]/ p' -e d )
39 COMPREPLY=( $( compgen -W "$helpcmds" -- "$cur" ) )
42 # Prevent space if an argument is desired
43 if [[ $COMPREPLY == *= ]]; then
49 complete -F _bitcoin_tx bitcoin-tx
54 # sh-indent-comment: t
55 # indent-tabs-mode: nil
57 # ex: ts=4 sw=4 et filetype=sh