diff options
author | WH-2099 <wh2099@outlook.com> | 2021-12-29 19:55:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-29 12:55:51 +0100 |
commit | 2acb3071cade6395c1dbcee31b6b8d198ebed66a (patch) | |
tree | c0cfa337d37b0f1cd21a0c5a041e4cbb8f4e3787 /plugins/pip/pip.plugin.zsh | |
parent | eec34b32fa586559af463b0d61256a7f5d257bea (diff) | |
download | zsh-2acb3071cade6395c1dbcee31b6b8d198ebed66a.tar.gz zsh-2acb3071cade6395c1dbcee31b6b8d198ebed66a.tar.bz2 zsh-2acb3071cade6395c1dbcee31b6b8d198ebed66a.zip |
fix(pip): don't overwrite `requirements.txt` in internal commands (#10061)
Diffstat (limited to 'plugins/pip/pip.plugin.zsh')
-rw-r--r-- | plugins/pip/pip.plugin.zsh | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index a58f5704a..7eb2d2a35 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -91,11 +91,21 @@ fi # Create requirements file alias pipreq="pip freeze > requirements.txt" -# Update all installed packages -alias pipupall="pipreq && sed -i 's/==/>=/g' requirements.txt && pip install -r requirements.txt --upgrade && rm -rf requirements.txt" - # Install packages from requirements file alias pipir="pip install -r requirements.txt" +# Update all installed packages +function pipupall { + # non-GNU xargs does not support nor need `--no-run-if-empty` + local xargs="xargs --no-run-if-empty" + xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" + pip list --outdated --format freeze | cut -d= -f1 | ${=xargs} pip install --upgrade +} + # Uninstalled all installed packages -alias pipunall="pipreq && pip uninstall -r requirements.txt -y && rm -rf requirements.txt" +function pipunall { + # non-GNU xargs does not support nor need `--no-run-if-empty` + local xargs="xargs --no-run-if-empty" + xargs --version 2>/dev/null | grep -q GNU || xargs="xargs" + pip list --format freeze | cut -d= -f1 | ${=xargs} pip uninstall +} |