In trying to make my .zshrc
neater, I stumbled over the following problem/question:
"How can I run the output of another command?". While I'm sure this is a simple problem, I just don't understand what I'm doing wrong.
I want to add pip-completion to my config. For this, I need to add the output of $ pip completion --zsh
to .zshrc
:
$ pip completion --zsh
pip zsh completion start
function _pip_completion {
local words cword
read -Ac words
read -cn cword
reply=( $( COMP_WORDS="$words[*]"
COMP_CWORD=$(( cword-1 ))
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null ))
}
compctl -K _pip_completion pip
pip zsh completion end
Now, the lines above simply don't look nice. Instead I tried adding the following line to .zshrc
:
eval $(pip completion --zshrc)
However, pip completion is not being "installed" (as opposed to when I add the lines themselves in .zshrc
), but I also don't get any errors.
I have a feeling zsh
doesn't evaluate the #
lines properly, but I'm not sure how to test it. when I run $ eval $(pip completion --zshrc)
no errors pop out.
Where am I going wrong? Is there a similar alternative to evaluating the output of $ pip completion --zsh
in my .zshrc
?
$IFS
using complex rules. By default$IFS
contains space, tab, newline and nul. – Stéphane Chazelas Jun 23 '21 at 15:28