mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Check python version at runtime for completions
Some things like pyenv can change what `python` refers to, so what we detect when we load the completions can become invalid later. Also mentioned in #3840.
This commit is contained in:
parent
f9664f224d
commit
52648acdc8
1 changed files with 10 additions and 11 deletions
|
@ -17,14 +17,13 @@ complete -c python -s x -d 'Skip first line of source, allowing use of non-Unix
|
||||||
complete -c python -a "(__fish_complete_suffix .py)"
|
complete -c python -a "(__fish_complete_suffix .py)"
|
||||||
complete -c python -a '-' -d 'Read program from stdin'
|
complete -c python -a '-' -d 'Read program from stdin'
|
||||||
|
|
||||||
switch (python -V 2>&1 | string replace -r '^.*\s([23])..*' '$1')[1]
|
# Version-specific completions
|
||||||
case 2
|
# We have to detect this at runtime because pyenv etc can change
|
||||||
complete -c python -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix'
|
# what `python` refers to.
|
||||||
complete -c python -s t --description "Warn on mixed tabs and spaces"
|
complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix'
|
||||||
complete -c python -s Q -x -a "old new warn warnall" --description "Division control"
|
complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s t --description "Warn on mixed tabs and spaces"
|
||||||
case 3
|
complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s Q -x -a "old new warn warnall" --description "Division control"
|
||||||
complete -c python -s q --description 'Don\'t print version and copyright messages on interactive startup'
|
complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -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 -n 'python -V 2>&1 | string match -rq "^.*\s3"' -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 -n 'python -V 2>&1 | string match -rq "^.*\s3"' -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'
|
complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -o bb -d 'Issue errors'
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in a new issue