environment-variableszshzsh-completion

How to setup completion of environment variable names in zsh?


In bash when I try to use autocompletion in double-quoted strings it works:

E.g.

echo "My home directory is $HO<t>"
# expands to
echo "My home directory is $HOME"

But when I try the same thing in zsh it just does nothing.

At the same time it works outside strings:

echo My\ home\ directory\ is\ $HO<t>
# expands to
echo My\ home\ directory\ is\ $HOME

Is it possible to make it work the same as bash?


Solution

  • There are two possible reasons why this doesn't work for you:

    As a workaround:

    1. Make sure you're using the code from the first bullet point.
    2. When you want to complete a parameter this way, first remove the final " from your string before pressing Tab.