From f70b1ffbbfb2cf67129eb35408055416c6d9bab5 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 20 Jul 2015 12:33:34 +0200 Subject: [PATCH] Normalize python* completion --- share/completions/python.fish | 31 ++++++++++++++++++- share/completions/python2.fish | 4 ++- share/completions/python3.fish | 4 ++- share/functions/__fish_complete_python.fish | 34 --------------------- 4 files changed, 36 insertions(+), 37 deletions(-) delete mode 100644 share/functions/__fish_complete_python.fish diff --git a/share/completions/python.fish b/share/completions/python.fish index 4c8eb4422..764478de3 100644 --- a/share/completions/python.fish +++ b/share/completions/python.fish @@ -1 +1,30 @@ -__fish_complete_python python +complete -c python -s B --description 'Don\'t write .py[co] files on import' +complete -c python -s c -x --description "Execute argument as command" +complete -c python -s d --description "Debug on" +complete -c python -s E --description "Ignore environment variables" +complete -c python -s h -l help --description "Display help and exit" +complete -c python -s i --description "Interactive mode after executing commands" +complete -c python -s m -d 'Run library module as a script (terminates option list)' -xa "( find /usr/lib/(eval python -V 2>| sed 's/ //; s/\..\$//; s/P/p/') \$PYTHONPATH -maxdepth 1 -name '*.py' -printf '%f\n' | sed 's/.py//')" +complete -c python -s O --description "Enable optimizations" +complete -c python -o OO --description "Remove doc-strings in addition to the -O optimizations" +complete -c python -s s --description 'Don\'t add user site directory to sys.path' +complete -c python -s S --description "Disable import of site module" +complete -c python -s u --description "Unbuffered input and output" +complete -c python -s v --description "Verbose mode" +complete -c python -s V --description "Display version and exit" +complete -c python -s W -x --description "Warning control" -a "ignore default all module once error" +complete -c python -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' +complete -c python -a "(__fish_complete_suffix .py)" +complete -c python -a '-' -d 'Read program from stdin' + +switch (eval python -V 2>&1 | head -n1 | sed 's/^.*[[:space:]]\([23]\)\..*/\1/') + case 2 + complete -c python -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix' + complete -c python -s t --description "Warn on mixed tabs and spaces" + complete -c python -s Q -x -a "old new warn warnall" --description "Division control" + case 3 + complete -c python -s q --description 'Don\'t print version and copyright messages on interactive startup' + complete -c python -s X -x -d 'Set implementation-specific option' + complete -c python -s b -d 'Issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str' + complete -c python -o bb -d 'Issue errors' +end diff --git a/share/completions/python2.fish b/share/completions/python2.fish index 223d92d85..3064545a6 100644 --- a/share/completions/python2.fish +++ b/share/completions/python2.fish @@ -1 +1,3 @@ -__fish_complete_python python2 +complete -c python2 -w python +# Override this to use python2 instead of python +complete -c python2 -s m -d 'Run library module as a script (terminates option list)' -xa "( find /usr/lib/(eval python2 -V 2>| sed 's/ //; s/\..\$//; s/P/p/') \$PYTHONPATH -maxdepth 1 -name '*.py' -printf '%f\n' | sed 's/.py//')" diff --git a/share/completions/python3.fish b/share/completions/python3.fish index 983b0e748..a90c40a10 100644 --- a/share/completions/python3.fish +++ b/share/completions/python3.fish @@ -1,2 +1,4 @@ -__fish_complete_python python3 +complete -c python3 -w python +# Override this to use python2 instead of python +complete -c python3 -s m -d 'Run library module as a script (terminates option list)' -xa "( find /usr/lib/(eval python3 -V 2>| sed 's/ //; s/\..\$//; s/P/p/') \$PYTHONPATH -maxdepth 1 -name '*.py' -printf '%f\n' | sed 's/.py//')" diff --git a/share/functions/__fish_complete_python.fish b/share/functions/__fish_complete_python.fish deleted file mode 100644 index 4fccdc435..000000000 --- a/share/functions/__fish_complete_python.fish +++ /dev/null @@ -1,34 +0,0 @@ -function __fish_complete_python -d 'Make completion for python' --argument-names cmd - complete -c $cmd -s B --description 'Don\'t write .py[co] files on import' - complete -c $cmd -s c -x --description "Execute argument as command" - complete -c $cmd -s d --description "Debug on" - complete -c $cmd -s E --description "Ignore environment variables" - complete -c $cmd -s h -l help --description "Display help and exit" - complete -c $cmd -s i --description "Interactive mode after executing commands" - complete -c $cmd -s m -d 'Run library module as a script (terminates option list)' -xa "( find /usr/lib/(eval $cmd -V 2>| sed 's/ //; s/\..\$//; s/P/p/') \$PYTHONPATH -maxdepth 1 -name '*.py' -printf '%f\n' | sed 's/.py//')" - complete -c $cmd -s O --description "Enable optimizations" - complete -c $cmd -o OO --description "Remove doc-strings in addition to the -O optimizations" - complete -c $cmd -s s --description 'Don\'t add user site directory to sys.path' - complete -c $cmd -s S --description "Disable import of site module" - complete -c $cmd -s u --description "Unbuffered input and output" - complete -c $cmd -s v --description "Verbose mode" - complete -c $cmd -s V --description "Display version and exit" - complete -c $cmd -s W -x --description "Warning control" -a "ignore default all module once error" - complete -c $cmd -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' - complete -c $cmd -a "(__fish_complete_suffix .py)" - complete -c $cmd -a '-' -d 'Read program from stdin' - - switch (eval $cmd -V 2>&1 | head -n1 | sed 's/^.*[[:space:]]\([23]\)\..*/\1/') - case 2 - complete -c $cmd -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix' - complete -c $cmd -s t --description "Warn on mixed tabs and spaces" - complete -c $cmd -s Q -x -a "old new warn warnall" --description "Division control" - - case 3 - complete -c $cmd -s q --description 'Don\'t print version and copyright messages on interactive startup' - complete -c $cmd -s X -x -d 'Set implementation-specific option' - complete -c $cmd -s b -d 'Issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str' - complete -c $cmd -o bb -d 'Issue errors' - - end -end