From 20395339a4455c605b273909c62d30b972aecb01 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 12 May 2018 23:40:40 -0500 Subject: [PATCH] Fix python{,2,3} argument completions Only the first non-switch parameter to python must be a .py file, but everything thereafter is "just another argument". This enables file completions for 2nd+ arguments. --- share/completions/python.fish | 4 ++-- share/completions/python2.fish | 4 ++-- share/completions/python3.fish | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/completions/python.fish b/share/completions/python.fish index ae5fc705c5cf..dfd127a2e761 100644 --- a/share/completions/python.fish +++ b/share/completions/python.fish @@ -14,8 +14,8 @@ complete -c python -s v -d "Verbose mode" complete -c python -s V -d "Display version and exit" complete -c python -s W -x -d "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 -fa "(__fish_complete_suffix .py)" -complete -c python -fa '-' -d 'Read program from stdin' +complete -c python -f -n '__fish_is_first_token' -a "(__fish_complete_suffix .py)" +complete -c python -f -n '__fish_is_first_token' -a '-' -d 'Read program from stdin' # Version-specific completions # We have to detect this at runtime because pyenv etc can change diff --git a/share/completions/python2.fish b/share/completions/python2.fish index a1a58bedb9a7..39950b6c9c7d 100644 --- a/share/completions/python2.fish +++ b/share/completions/python2.fish @@ -13,8 +13,8 @@ complete -c python2 -s v -d "Verbose mode" complete -c python2 -s V -d "Display version and exit" complete -c python2 -s W -x -d "Warning control" -a "ignore default all module once error" complete -c python2 -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python2 -fa "(__fish_complete_suffix .py)" -complete -c python2 -fa '-' -d 'Read program from stdin' +complete -c python2 -f -n '__fish_is_first_token' -a "(__fish_complete_suffix .py)" +complete -c python2 -f -n '__fish_is_first_token' -a '-' -d 'Read program from stdin' complete -c python2 -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix' complete -c python2 -s t -d "Warn on mixed tabs and spaces" complete -c python2 -s Q -x -a "old new warn warnall" -d "Division control" diff --git a/share/completions/python3.fish b/share/completions/python3.fish index 706f6818415f..ea6cf259b7e8 100644 --- a/share/completions/python3.fish +++ b/share/completions/python3.fish @@ -13,8 +13,8 @@ complete -c python3 -s v -d "Verbose mode" complete -c python3 -s V -d "Display version and exit" complete -c python3 -s W -x -d "Warning control" -a "ignore default all module once error" complete -c python3 -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python3 -fa "(__fish_complete_suffix .py)" -complete -c python3 -fa '-' -d 'Read program from stdin' +complete -c python3 -n '__fish_is_first_token' -fa "(__fish_complete_suffix .py)" +complete -c python3 -f -n '__fish_is_first_token' -a '-' -d 'Read program from stdin' complete -c python3 -s q -d 'Don\'t print version and copyright messages on interactive startup' complete -c python3 -s X -x -d 'Set implementation-specific option' complete -c python3 -s b -d 'Issue warnings about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str'