Skip to content
Closed
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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,36 @@ This will be indicated in the output with one of the following suffixes:
- [Python extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VS Code.
- [pip-requirements.el](https://github.com/Wilfred/pip-requirements.el) for Emacs.

### Shell completions

`pip-tools` supports shell completions for `pip-compile` and `pip-sync`.

For Bash, add this to `~/.bashrc`:

```bash
eval "$(_PIP_COMPILE_COMPLETE=bash_source pip-compile)"
eval "$(_PIP_SYNC_COMPLETE=bash_source pip-sync)"
```

For Zsh, add this to `~/.zshrc`:

```bash
eval "$(_PIP_COMPILE_COMPLETE=zsh_source pip-compile)"
eval "$(_PIP_SYNC_COMPLETE=zsh_source pip-sync)"
```

For Fish, add this to `~/.config/fish/completions/pip-compile.fish`:

```fish
_PIP_COMPILE_COMPLETE=fish_source pip-compile | source
```

And this to `~/.config/fish/completions/pip-sync.fish`:

```fish
_PIP_SYNC_COMPLETE=fish_source pip-sync | source
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather we didn't instruct users to modify their profile (~/.bashrc or ~/.zshrc), although with fish it's almost unavoidable.

I've found many times that

  • an experienced user doesn't need such instruction
  • novice users will run commands which modify their profile multiple times, resulting in a repetitive and sometimes broken profile

Can we instead provide the eval-based version of this, and trust that users who need to use the non-eval version know what to do?

In particular, I'd like us to imitate the current click docs: https://click.palletsprojects.com/en/stable/shell-completion/#enabling-completion

Note that the docs say "add this to ~/.bashrc" and don't provide a command for doing so automatically.

So I'd much rather see:

  • for bash, add these two evals to your ~/.bashrc
  • for zsh, add these two evals to your ~/.zshrc
  • leave the fish doc alone

Not only is fish more complicated to do any other way, it's also a much more niche shell, with typically more advanced users.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I said "leave the fish doc alone", I meant that the prior version looked correct to me, namely:

$ _PIP_COMPILE_COMPLETE=fish_source pip-compile > ~/.config/fish/completions/pip-compile.fish
$ _PIP_SYNC_COMPLETE=fish_source pip-sync > ~/.config/fish/completions/pip-sync.fish

The current version is telling people to put the source snippet into a dedicated completion file, which is a very unusual way to do it and not in line with how click documents this feature.

Could you please revert that part?

### Deprecations

This section lists `pip-tools` features that are currently deprecated.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+shell_completions.doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added documentation for shell completions for `pip-compile` and `pip-sync` -- by {user}`Ahmed-AdelB`.