typer icon indicating copy to clipboard operation
typer copied to clipboard

[BUG] typer doesn't respect ZDOTDIR env var when adding autocompletion for zsh

Open m-rey opened this issue 5 years ago • 2 comments

Describe the bug

When autocompletion is created in typer, the necessary changes are made in $HOME/.zshrc: https://github.com/tiangolo/typer/blob/a93e6b2f86a34fd82741ae837b9b188083a5e9c0/typer/completion.py#L225 However, the path to the directory where the .zshrc file is in, can be set by the environment variable ZDOTDIR. Therefore, typer should check first if the environment variable ZDOTDIR is set and valid and use it to find .zshrc and add the necessary line for auto-completion. If it is invalid or simply not set, the default path to $HOME/.zshrc can be used.

To Reproduce

zsh
mkdir "$HOME/not_default_zsh_dir"
touch "$HOME/not_default_zsh_dir/.zshrc"
export ZDOTDIR="$HOME/not_default_zsh_dir"
# try using the typer autocompletion now, it should fail

Expected behavior

typer should check for the ZDOTDIR env var and use it as base to locate .zshrc instead of always using HOME.

m-rey avatar Oct 01 '20 07:10 m-rey

Bug still present in Typer 0.3.2

mjmare avatar Aug 15 '21 19:08 mjmare

I also experienced this bug in Typer 0.15.2. It tried to install the completions into ~/.zfunc while ignoring the fact I have $ZDOTDIR set, so the completions don't work.

ShaiAvr avatar Apr 03 '25 16:04 ShaiAvr