Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/html/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ pip_check
pip_lock
```

```{toctree}
:maxdepth: 1
:caption: Command-line usability and shell integration

pip_completion
```

```{toctree}
:maxdepth: 1
:caption: Handling Distribution Files
Expand Down
72 changes: 72 additions & 0 deletions docs/html/cli/pip_completion.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _`pip completion`:

==============
pip completion
==============


Usage
=====

.. tab:: Unix/macOS

.. pip-command-usage:: completion "python -m pip"

.. tab:: Windows

.. pip-command-usage:: completion "py -m pip"


Description
===========

.. pip-command-description:: completion

Options
=======

.. pip-command-options:: completion


Example Setups
==============

Enable pip tab completion in your shell:

.. tab:: Bash

Add the following line to your ~/.bashrc:

.. code-block:: console

echo 'eval "$(python -m pip completion --bash)"' >> ~/.bashrc

Then reload your shell or run ``source ~/.bashrc`` to enable it immediately.

.. tab:: Zsh

Add the following line to your ~/.zshrc:

.. code-block:: console

echo 'eval "$(python -m pip completion --zsh)"' >> ~/.zshrc

Reload your shell or run ``source ~/.zshrc``.

.. tab:: PowerShell

Add the following line to your PowerShell profile:

.. code-block:: powershell

python -m pip completion --powershell | Out-String | Invoke-Expression

Restart your PowerShell session for the changes to take effect.

.. note::

On Windows, ``pip.exe`` may point to a specific Python installation
(e.g. ``C:\Users\<user>\AppData\Local\Programs\Python\Python313\python.exe -m pip``).
In this case, tab completion works for that exact command. To enable
completion for the ``pip`` command itself in PowerShell, you can use
``Register-ArgumentCompleter`` with ``CommandName pip``.
1 change: 1 addition & 0 deletions news/13536.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``pip completion`` documentation.
2 changes: 2 additions & 0 deletions src/pip/_internal/commands/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class CompletionCommand(Command):
"""A helper command to be used for command completion."""

ignore_require_venv = True
usage = """
%prog [options]"""

def add_options(self) -> None:
self.cmd_opts.add_option(
Expand Down