0

I created a a CLI tool with PicoCLI. The library generates an auto-complete script. This works fine when sourced manually, i.e.

source /path/to/script

But when I put the line into ~/.zshrc it doesn't. No errors, just doesn't work. Tried different things like . /path/to/script, source <(cat /path/to/script), added execution permissions, added autoload -U +X compinit && compinit & autoload -U +X bashcompinit && bashcompinit (see here). No success, no idea what's wrong. According to the docs it should be fine (see here).

Thanks for any suggestion!

ss1
  • 1,009
  • 15
  • 32
  • 1
    There doesn't appear to be anything wrong with your source statements. Some debugging steps to try: a) `zsh -x` - it'll dump a lot of statements, see if you can find the pico script in there. b) Add `echo` statements to `~/.zshrc` and the autocomplete script to ensure they are being invoked when you expect. c) make sure you're indeed running `zsh` (sometimes the active shell gets switched unexpectedly): https://stackoverflow.com/a/3327022/9307265 – Gairfowl Oct 04 '21 at 02:48
  • 1
    @ss1 : _doesn't work_ is a poor problem description: For sure, your file is being sourced, because you would have gotten an error message afterwards, and you can turn on tracing with `set -x` to see, what commands ar executed. You could also do a `echo $ZSH_VERSION` at the start of your .zshrc to make sure that you get the same version as in the zsh instance, where you claim that it works. – user1934428 Oct 04 '21 at 10:14
  • 1
    Or, your `.zshrc` file exits early, before your source command is even reached. This is why we need a [mcve] to diagnose your actual problem. – chepner Oct 04 '21 at 12:39
  • Did you find any reason? I am facing a similar issue. – Abdullah Al Maruf - Tuhin Oct 19 '22 at 21:24

0 Answers0