typer
typer copied to clipboard
[BUG] typer doesn't respect ZDOTDIR env var when adding autocompletion for zsh
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.
Bug still present in Typer 0.3.2
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.