Cache pip{,2,3,env} completions

These take a *lot* of time - `pip3` takes 180ms, `pipenv` takes 320ms
on my system.

Note that this removes a number of obsolete workarounds - pip's was
fixed in 2017 (and pip2 is less and less of a thing), pipenv's change
was in 2019.

Since these are packaging tools with access to the internet they
should really be kept up-to-date, so it is unlikely someone still uses
these old versions.
This commit is contained in:
Fabian Boehm 2024-01-16 17:32:11 +01:00
parent e5b2c3e4be
commit b4d9189fd3
4 changed files with 8 additions and 20 deletions

View file

@ -1 +1,2 @@
pip completion --fish 2>/dev/null | source
__fish_cache_sourced_completions pip completion --fish 2>/dev/null
or pip completion --fish 2>/dev/null | source

View file

@ -1,5 +1,2 @@
# pip[2|3] emits (or emitted) completions with the wrong command name
# See discussion at https://github.com/fish-shell/fish-shell/pull/4448
# and pip bug at https://github.com/pypa/pip/pull/4755
# Keep this even after pip fix is upstreamed for users not on the latest pip
pip2 completion --fish 2>/dev/null | string replace -r -- " -c\s+pip\b" " -c pip2" | source
__fish_cache_sourced_completions pip2 completion --fish 2>/dev/null
or pip2 completion --fish 2>/dev/null | source

View file

@ -1,5 +1,2 @@
# pip[2|3] emits (or emitted) completions with the wrong command name
# See discussion at https://github.com/fish-shell/fish-shell/pull/4448
# and pip bug at https://github.com/pypa/pip/pull/4755
# Keep this even after pip fix is upstreamed for users not on the latest pip
pip3 completion --fish 2>/dev/null | string replace -r -- " -c\s+pip\b" " -c pip3" | source
__fish_cache_sourced_completions pip3 completion --fish 2>/dev/null
or pip3 completion --fish 2>/dev/null | source

View file

@ -1,12 +1,5 @@
# try new completion generation of click first
set -l comps (_PIPENV_COMPLETE=fish_source pipenv 2>/dev/null)
if test -z "$comps" || string match -q 'Usage:*' -- $comps
# fall back to older click-completion used in prior versions
set comps (_PIPENV_COMPLETE=source-fish pipenv --completion 2>/dev/null)
end
set -q comps[1] && printf %s\n $comps | source
_PIPENV_COMPLETE=fish_source __fish_cache_sourced_completions pipenv 2>/dev/null
or _PIPENV_COMPLETE=fish_source pipenv 2>/dev/null | source
# manual workaround for pipenv run command completion until this is supported by the built-in mechanism
complete -c pipenv -n "__fish_seen_subcommand_from run" -a "(__fish_complete_subcommand --fcs-skip=2)" -x