Heroku CLI Autocomplete does not respect `$ZSH_COMPDUMP` location for zsh.
- Dominant language
- TypeScript
- Stars
- 889
- Forks
- 236
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 33
Description
Do you want to request a *feature* or report a *bug*?
-----------------------------------------------------
This is a bug report.
- Heroku version: `heroku/7.59.2 darwin-x64 node-v12.21.0`
- OS: `macOS Monterey 12.2.1`
What is the current behavior?
-----------------------------
After installing Heroku CLI Autocomplete by running `heroku autocomplete` and following the install instructions, a `.zcompdump` file will be created at `$ZDOTDIR` every time `.zshrc` is run, or at `$HOME` if `$ZDOTDIR` is not set.
This is because no `-d` option is given in `~/Library/Caches/heroku/autocomplete/zsh_setup` (macOS), which is a file that is created by [`create.ts`](https://github.com/heroku/cli/blob/67b9080ad0b48e654d799bced119cbab768c759a/packages/autocomplete/src/commands/autocomplete/create.ts) when running `heroku autocomplete`.
What is the expected behavior?
------------------------------
If the environment variable [`$ZSH_COMPDUMP`](https://github.com/ohmyzsh/ohmyzsh/wiki/Design#variables-omz-reads) is set, the `.zcompdump` file should be created there instead of `$ZDOTDIR` or `$HOME`.
So if [`$ZSH_COMPDUMP`](https://github.com/ohmyzsh/ohmyzsh/wiki/Design#variables-omz-reads) exists, `compinit -d "$ZSH_COMPDUMP";` should run instead of just `compinit;`.
A potential implementation for a fix would be replacing [line 229](https://github.com/heroku/cli/blob/67b9080ad0b48e654d799bced119cbab768c759a/packages/autocomplete/src/commands/autocomplete/create.ts#L229) in with the following check:
```zsh
if [[ -z "$ZSH_COMPDUMP" ]]; then
compinit;
else
compinit -d "$ZSH_COMPDUMP";
fi
```
This would not change any behavior for anyone without [`$ZSH_COMPDUMP`](https://github.com/ohmyzsh/ohmyzsh/wiki/Design#variables-omz-reads) set, and respects [`$ZSH_COMPDUMP`](https://github.com/ohmyzsh/ohmyzsh/wiki/Design#variables-omz-reads) for those who do.
Contributor guide
Assessment
This issue has not been assessed yet.