zsh: setopt magic_equal_subst
β’ 90 words β’ 1 min β’ updated
β οΈ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
Problem statement: Write the following command line in zsh:
shell
% terraform plan -var-file=../../../config/global-dns-changer-Now press <TAB>.
Expected: Filename expansion.
Observed:
No matches for: `filename' or `file'Ugh. How about some magic πͺ?
shell
setopt magic_equal_substNow:
shell
% terraform plan -var-file=../../../config/global-dns-changer-<TAB>
completing file
global-dns-changer-{foo}.tfvars global-dns-changer-{bar}.tfvarsYay!
There’s a workaround if you don’t want to set the aforementioned option. Just
remove the = character:
shell
% terraform plan -var-file ../../../config/global-dns-changer-<TAB>
completing file
global-dns-changer-{foo}.tfvars global-dns-changer-{bar}.tfvarsI find it’s more convenient to have this option work in both situations though.
(via Reddit)