From cc5100d1e9e3d843ab93a12a5b0bac71ae0425f3 Mon Sep 17 00:00:00 2001 From: Neil Girdhar Date: Fri, 9 Dec 2022 04:07:52 -0500 Subject: [PATCH] feat(pip): add several aliases (#10647) --- plugins/pip/README.md | 8 ++++++++ plugins/pip/pip.plugin.zsh | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/plugins/pip/README.md b/plugins/pip/README.md index 88d88227e..70d40c79f 100644 --- a/plugins/pip/README.md +++ b/plugins/pip/README.md @@ -22,6 +22,14 @@ the next time you autocomplete `pip install`. | Alias | Description | | :------- | :-------------------------------------------- | +| pipi | Install packages | +| pipig | Install package from GitHub repository | +| pipigb | Install package from GitHub branch | +| pipigp | Install package from GitHub pull request | +| pipu | Upgrade packages | +| pipun | Uninstall packages | +| pipgi | Grep through installed packages | +| piplo | List outdated packages | | pipreq | Create requirements file | | pipir | Install packages from `requirements.txt` file | | pipupall | Update all installed packages | diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 90e39e118..bf1aafd4a 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -88,6 +88,12 @@ else alias pip="noglob pip" fi +alias pipi="pip install" +alias pipu="pip install --upgrade" +alias pipun="pip uninstall" +alias pipgi="pip freeze | grep" +alias piplo="pip list -o" + # Create requirements file alias pipreq="pip freeze > requirements.txt" @@ -102,10 +108,28 @@ function pipupall { pip list --outdated | awk 'NR > 2 { print $1 }' | ${=xargs} pip install --upgrade } -# Uninstalled all installed packages +# Uninstall all installed packages 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 } + +# Install from GitHub repository +function pipig { + pip install "git+https://github.com/$1.git" +} +compdef _pip pipig + +# Install from GitHub branch +function pipigb { + pip install "git+https://github.com/$1.git@$2" +} +compdef _pip pipigb + +# Install from GitHub pull request +function pipigp { + pip install "git+https://github.com/$1.git@refs/pull/$2/head" +} +compdef _pip pipigp