summaryrefslogtreecommitdiff
path: root/plugins/pip
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2022-01-01 02:26:11 -0600
committerTuowen Zhao <ztuowen@gmail.com>2022-01-01 02:26:11 -0600
commit49edbf438ed690c76e6b2af80368c59404cf0167 (patch)
tree129b3adb2f5f39a1329a426a3b7d51ed2c2290c1 /plugins/pip
parent1bc186dabe12b3d01b2257e82f3a104c48b8b3c7 (diff)
parent78c91ccbf99c77bd4d9cdb74279a40776721f66d (diff)
downloadzsh-49edbf438ed690c76e6b2af80368c59404cf0167.tar.gz
zsh-49edbf438ed690c76e6b2af80368c59404cf0167.tar.bz2
zsh-49edbf438ed690c76e6b2af80368c59404cf0167.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/pip')
-rw-r--r--plugins/pip/_pip2
-rw-r--r--plugins/pip/pip.plugin.zsh24
2 files changed, 20 insertions, 6 deletions
diff --git a/plugins/pip/_pip b/plugins/pip/_pip
index a5adead4a..e03be6afe 100644
--- a/plugins/pip/_pip
+++ b/plugins/pip/_pip
@@ -13,7 +13,7 @@ _pip_all() {
}
_pip_installed() {
- installed_pkgs=(`pip freeze | cut -d '=' -f 1`)
+ installed_pkgs=($($service freeze | cut -d '=' -f 1))
}
local -a _1st_arguments
diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh
index 629147bae..7eb2d2a35 100644
--- a/plugins/pip/pip.plugin.zsh
+++ b/plugins/pip/pip.plugin.zsh
@@ -82,16 +82,30 @@ zsh-pip-test-clean-packages() {
fi
}
-alias pip="noglob pip" # allows square brackets for pip command invocation
+if (( $+commands[pip3] && !$+commands[pip] )); then
+ alias pip="noglob pip3"
+else
+ alias pip="noglob pip"
+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
+}