Repository navigation
How do I avoid adding a trailing space to a completion item? #1428
Replies: 1 comment
|
There's no per-item "no space" flag in Typer's Click exposes import click.shell_completion as sc
class NoSpaceZsh(sc.ZshComplete):
source_template = sc.ZshComplete.source_template.replace(
"compadd -U -V unsorted -a completions",
"compadd -S '' -U -V unsorted -a completions",
)
sc.add_completion_class(NoSpaceZsh, name="zsh") # replaces the built-in zsh class
import typer
app = typer.Typer()
# ... your commands/autocompletion as beforeI verified on Typer 0.27 / Click 8.5 that the rendered zsh completion script then contains You'll need to re-install completion after this ( Two things to know:
The zsh override above is the clean, tested one for your macOS setup. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
I am specifying a remote path of sorts. It is almost to be treated as a
pathlib.Path. I have a completion function defined to return parts of the path one by one and between slashes I don't want a space when I select a completion item by typing on it.A space is appended anyway.
Operating System
macOS
Operating System Details
No response
Typer Version
0.20.0
Python Version
3.14
Additional Context
No response
All reactions