Skip to content

Commit 9a87ccf

Browse files
authored
[complete][zsh] Fixing issue with compgen function not being found (#499)
Depending on your version of zsh, you may not have `autoload compinit` called in your `.zshrc` file, which results in the following error (tested on a macOS): complete:13: command not found: compdef I found the solution here, which worked when tested: https://stackoverflow.com/a/76476988/1848826
1 parent ebd80fb commit 9a87ccf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Added `limit` parameter to `option().counted()` to limit the number of times the option can be used. You can either clamp the value to the limit, or throw an error if the limit is exceeded. ([#483](https://github.com/ajalt/clikt/issues/483))
66
- Added `Context.registerClosable` and `Context.callOnClose` to allow you to register cleanup actions that will be called when the command exits. ([#395](https://github.com/ajalt/clikt/issues/395))
77

8+
### Fixed
9+
- Make sure auto complete script works on zsh, fixing the error `complete:13: command not found: compdef` ([#499](https://github.com/ajalt/clikt/pull/499))
10+
811
## 4.2.2
912
### Changed
1013
- Options and arguments can now reference option groups in their `defaultLazy` and other finalization blocks. They can also freely reference each other, including though chains of references. ([#473](https://github.com/ajalt/clikt/issues/473))

clikt/src/commonMain/kotlin/com/github/ajalt/clikt/completion/BashCompletionGenerator.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ internal object BashCompletionGenerator {
3838
if (zsh) {
3939
append(
4040
"""
41-
|autoload bashcompinit
41+
|autoload -Uz compinit
42+
|compinit
43+
|autoload -Uz bashcompinit
4244
|bashcompinit
4345
|
4446
|

0 commit comments

Comments
 (0)