summaryrefslogtreecommitdiff
path: root/completions/python
diff options
context:
space:
mode:
Diffstat (limited to 'completions/python')
-rw-r--r--completions/python33
1 files changed, 19 insertions, 14 deletions
diff --git a/completions/python b/completions/python
index f8ef6d0c..5e69ff12 100644
--- a/completions/python
+++ b/completions/python
@@ -2,9 +2,15 @@
_python_modules()
{
- COMPREPLY+=( $( compgen -W \
- "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \
- 2>/dev/null )" -- "$cur" ) )
+ COMPREPLY+=( $(compgen -W \
+ "$(${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \
+ 2>/dev/null)" -- "$cur") )
+}
+
+_python_warning_actions()
+{
+ COMPREPLY+=( $(compgen -W "ignore default all module once error" \
+ ${prefix:+-P "$prefix"} -- "$cur") )
}
_python()
@@ -21,26 +27,25 @@ _python()
esac
case $prev in
- -'?'|-h|--help|-V|--version|-c|-X)
+ --help|--version|-!(-*)[?hVcX])
return
;;
- -m)
+ -!(-*)m)
_python_modules "$1"
return
;;
- -Q)
- COMPREPLY=( $( compgen -W "old new warn warnall" -P "$prefix" \
- -- "$cur" ) )
+ -!(-*)Q)
+ COMPREPLY=( $(compgen -W "old new warn warnall" -P "$prefix" \
+ -- "$cur") )
return
;;
- -W)
- COMPREPLY=( $( compgen -W "ignore default all module once error" \
- -P "$prefix" -- "$cur" ) )
+ -!(-*)W)
+ _python_warning_actions
return
;;
--jit)
# TODO: quite a few others, parse from "--jit help" output?
- COMPREPLY=( $( compgen -W "help off" -- "$cur" ) )
+ COMPREPLY=( $(compgen -W "help off" -- "$cur") )
return
;;
!(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?))
@@ -50,12 +55,12 @@ _python()
# if -c or -m is already given, complete all kind of files.
- if [[ "${words[@]::$cword}" == *\ -[cm]\ * ]]; then
+ if [[ "${words[*]::$cword}" == *\ -[cm]\ * ]]; then
_filedir
elif [[ "$cur" != -* ]]; then
_filedir 'py?([cowz])'
else
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
fi
} &&
complete -F _python python python2 python3 pypy pypy3 micropython