2009-05-27 18:49:01 +02:00
|
|
|
# bash completion for python
|
|
|
|
|
2011-04-05 00:35:51 +03:00
|
|
|
have python || return
|
|
|
|
|
2009-05-27 18:49:01 +02:00
|
|
|
_python()
|
|
|
|
{
|
2011-04-20 23:08:37 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-10-04 19:42:50 +02:00
|
|
|
|
2009-12-30 00:39:59 +01:00
|
|
|
case $prev in
|
2010-11-21 20:36:09 +02:00
|
|
|
-'?'|-h|--help|-V|--version|-c|-m)
|
2010-11-21 20:30:42 +02:00
|
|
|
return 0
|
|
|
|
;;
|
2010-11-21 20:00:34 +02:00
|
|
|
-Q)
|
|
|
|
COMPREPLY=( $( compgen -W "old new warn warnall" -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
-W)
|
|
|
|
COMPREPLY=( $( compgen -W "ignore default all module once error" \
|
|
|
|
-- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2011-01-10 20:31:57 +02:00
|
|
|
!(?(*/)python*([0-9.])|-?))
|
2011-04-20 23:08:37 +03:00
|
|
|
[[ $cword -lt 2 || ${words[cword-2]} != -@(Q|W) ]] \
|
2011-01-10 20:26:22 +02:00
|
|
|
&& _filedir
|
2010-11-21 20:00:34 +02:00
|
|
|
;;
|
2009-10-04 19:42:50 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
# if '-c' is already given, complete all kind of files.
|
2011-04-20 23:08:37 +03:00
|
|
|
local i
|
|
|
|
for (( i=0; i < ${#words[@]}-1; i++ )); do
|
|
|
|
if [[ ${words[i]} == -c ]]; then
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$cur" != -* ]]; then
|
2010-11-21 20:35:25 +02:00
|
|
|
_filedir 'py?([co])'
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
2011-04-27 22:22:49 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
2009-05-27 18:49:01 +02:00
|
|
|
} &&
|
2010-11-21 20:02:12 +02:00
|
|
|
complete -F _python python python2 python3
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|