]> git.phdru.name Git - dotfiles.git/blobdiff - .bash_completion.d/python-pip
.bashrc: Extract oft-edited completion to a separate file
[dotfiles.git] / .bash_completion.d / python-pip
diff --git a/.bash_completion.d/python-pip b/.bash_completion.d/python-pip
new file mode 100644 (file)
index 0000000..57aaf06
--- /dev/null
@@ -0,0 +1,17 @@
+delegate_completion python python2.7 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
+
+if type -p pip >/dev/null 2>&1; then
+    _PIP=pip
+elif type -p pip3 >/dev/null 2>&1; then
+    _PIP=pip3
+fi
+
+if [ -n "$_PIP" ]; then
+    _pip_completion_loader() {
+        eval "`$_PIP completion --bash`"
+        complete -F _pip_completion pip pip2 pip2.7 pip3 pip3.4 pip3.5 pip3.6 pip3.7 pip3.8 pip3.9 pip3.10 pip3.11 pip3.12
+        unset _pip_completion_loader
+        return 124
+    }
+    complete -F _pip_completion_loader pip pip2 pip2.7 pip3 pip3.4 pip3.5 pip3.6 pip3.7 pip3.8 pip3.9 pip3.10 pip3.11 pip3.12
+fi