summaryrefslogtreecommitdiff
path: root/completions/python
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2017-09-25 23:46:54 -0300
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2017-09-25 23:46:54 -0300
commit6d88f1055806932d9291f96847d2b691cccda2cd (patch)
tree0ff79eedaa8a239331256048981deedbd0721965 /completions/python
parent059a87a5936cfebfd2d71ab8057002cafb2ea051 (diff)
downloadbash-completion-6d88f1055806932d9291f96847d2b691cccda2cd.tar.gz
New upstream version 2.7upstream/2.7
Diffstat (limited to 'completions/python')
-rw-r--r--completions/python62
1 files changed, 34 insertions, 28 deletions
diff --git a/completions/python b/completions/python
index 9c7cec13..758b44ef 100644
--- a/completions/python
+++ b/completions/python
@@ -2,56 +2,62 @@
_python_modules()
{
- COMPREPLY+=( $( compgen -W "$( ${1:-python} -c 'import pkgutil
-for mod in pkgutil.iter_modules(): print(mod[1])' )" 2>/dev/null -- "$cur" ) )
+ COMPREPLY+=( $( compgen -W \
+ "$( ${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python 2>/dev/null )" \
+ -- "$cur" ) )
}
_python()
{
- local cur prev words cword
+ local cur prev words cword prefix
_init_completion || return
+ case $cur in
+ -[QWX]?*)
+ prefix=${cur:0:2}
+ prev=$prefix
+ cur=${cur:2}
+ ;;
+ esac
+
case $prev in
- -'?'|-h|--help|-V|--version|-c)
- return 0
+ -'?'|-h|--help|-V|--version|-c|-X)
+ return
;;
-m)
_python_modules "$1"
- return 0
+ return
;;
-Q)
- COMPREPLY=( $( compgen -W "old new warn warnall" -- "$cur" ) )
- return 0
+ COMPREPLY=( $( compgen -W "old new warn warnall" -P "$prefix" \
+ -- "$cur" ) )
+ return
;;
-W)
COMPREPLY=( $( compgen -W "ignore default all module once error" \
- -- "$cur" ) )
- return 0
+ -P "$prefix" -- "$cur" ) )
+ return
;;
- !(?(*/)python*([0-9.])|-?))
- [[ $cword -lt 2 || ${words[cword-2]} != -@(Q|W) ]] \
- && _filedir
+ --jit)
+ # TODO: quite a few others, parse from "--jit help" output?
+ COMPREPLY=( $( compgen -W "help off" -- "$cur" ) )
+ return
+ ;;
+ !(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?))
+ [[ $cword -lt 2 || ${words[cword-2]} != -[QWX] ]] && _filedir
;;
esac
- # if '-c' is already given, complete all kind of files.
- local i
- for (( i=0; i < ${#words[@]}-1; i++ )); do
- if [[ ${words[i]} == -c ]]; then
- _filedir
- fi
- done
-
-
- if [[ "$cur" != -* ]]; then
- _filedir 'py?([co])'
+ # if -c or -m is already given, complete all kind of files.
+ if [[ "${words[@]::$cword}" == *\ -[cm]\ * ]]; then
+ _filedir
+ elif [[ "$cur" != -* ]]; then
+ _filedir 'py?([cowz])'
else
COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
fi
-
- return 0
} &&
-complete -F _python python python2 python3
+complete -F _python python python2 python3 pypy pypy3 micropython
-# ex: ts=4 sw=4 et filetype=sh
+# ex: filetype=sh