Mercurial > hg
changeset 3486:f699d4eb25d9
bash_completion: qguard
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sun, 22 Oct 2006 01:02:13 -0300 |
parents | 26285469db9b |
children | 46958e428fcd |
files | contrib/bash_completion |
diffstat | 1 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/bash_completion Sun Oct 22 01:02:06 2006 -0300 +++ b/contrib/bash_completion Sun Oct 22 01:02:13 2006 -0300 @@ -370,6 +370,43 @@ COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$guards' -- "$cur")) } +_hg_cmd_qguard() +{ + local prefix='' + + if [[ "$cur" == +* ]]; then + prefix=+ + elif [[ "$cur" == -* ]]; then + prefix=- + fi + local ncur=${cur#[-+]} + + if ! [ "$prefix" ]; then + _hg_ext_mq_patchlist qseries + return + fi + + local guards=$(_hg_ext_mq_guards) + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur")) +} + +_hg_opt_qguard() +{ + local i + for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do + if [[ ${COMP_WORDS[i]} != -* ]]; then + if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then + _hg_cmd_qguard + return 0 + fi + elif [ "${COMP_WORDS[i]}" = -- ]; then + _hg_cmd_qguard + return 0 + fi + done + return 1 +} + # hbisect _hg_cmd_bisect()