Skip to content
Myr

🐛 Fix `zsh` autocompletion installation (#237)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alex Jurkiewicz · committed by GitHub · parent 90f3e61 · Browse files · 1 file+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: svlandeg <svlandeg@github.com>
  • Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>

Diff stats

1 file+10 added−10 removed

  • other:+10 added−10 removed

1 file+10 added−10 removed

modified:typer/_completion_shared.py+10 added-10 removed
126 unmodified lines
127 zshrc_path.parent.mkdir(parents=True, exist_ok=True)128 zshrc_content = ""129 if zshrc_path.is_file():130 zshrc_content = zshrc_path.read_text()131 completion_init_lines = [132 "autoload -Uz compinit",133 "compinit",134 "zstyle ':completion:*' menu select",135 "fpath+=~/.zfunc",136 ]137 for line in completion_init_lines:138 if line not in zshrc_content: # pragma: no cover139 zshrc_content += f"\n{line}"140 zshrc_content += "\n"131 completion_line = "fpath+=~/.zfunc; autoload -Uz compinit; compinit"132 if completion_line not in zshrc_content:133 zshrc_content += f"\n{completion_line}\n"134 style_line = "zstyle ':completion:*' menu select"135 # TODO: consider setting the style only for the current program136 # style_line = f"zstyle ':completion:*:*:{prog_name}:*' menu select"137 # Install zstyle completion config only if the user doesn't have a customization138 if "zstyle" not in zshrc_content:139 zshrc_content += f"\n{style_line}\n"140 zshrc_content = f"{zshrc_content.strip()}\n"141 zshrc_path.write_text(zshrc_content)142 # Install completion under ~/.zfunc/143 path_obj = Path.home() / f".zfunc/_{prog_name}"144 path_obj.parent.mkdir(parents=True, exist_ok=True)
96 unmodified lines