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()
|
|
|
|
{
|
2009-10-04 19:42:50 +02:00
|
|
|
local prev cur i
|
|
|
|
|
|
|
|
COMPREPLY=()
|
2010-02-08 17:25:08 +01:00
|
|
|
_get_comp_words_by_ref cur prev
|
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-01-10 20:26:22 +02:00
|
|
|
[[ $COMP_CWORD -lt 2 || ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] \
|
|
|
|
&& _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.
|
|
|
|
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
|
|
|
if [[ ${COMP_WORDS[i]} == -c ]]; then
|
|
|
|
_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
|
2010-11-21 20:05:06 +02: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
|