How stop zsh from eating space before pipe symbol?
I suppose you mean that when you TAB
complete a command / filename a space is added automatically, but after pressing |
it vanishes again.
Otherwise I can't reproduce that effect.
However, in that case the solution should be as simple as
ZLE_REMOVE_SUFFIX_CHARS=""
The explanation is a litly bit tricky, so I simply quote man zshparam
ZLE_REMOVE_SUFFIX_CHARS
/ZLE_SPACE_SUFFIX_CHARS
These parameters are used by the line editor. In certain circumstances suffixes (typically space or slash) added by the completion system will be removed automatically, either because the next editing command was not an insertable character, or because the character was marked as requiring the suffix to be removed.These variables can contain the sets of characters that will cause the suffix to be removed. If
ZLE_REMOVE_SUFFIX_CHARS
is set, those characters will cause the suffix to be removed; ifZLE_SPACE_SUFFIX_CHARS
is set, those characters will cause the suffix to be removed and replaced by a space.If
ZLE_REMOVE_SUFFIX_CHARS
is not set, the default behaviour is equivalent to:ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
If
ZLE_REMOVE_SUFFIX_CHARS
is set but is empty, no characters have this behaviour.ZLE_SPACE_SUFFIX_CHARS
takes precedence, so that the following:ZLE_SPACE_SUFFIX_CHARS=$'&|'
causes the characters
&
and|
to remove the suffix but to replace it with a space.To illustrate the difference, suppose that the option
AUTO_REMOVE_SLASH
is in effect and the directory DIR has just been completed, with an appended/
, following which the user types&
. The default result isDIR&
. WithZLE_REMOVE_SUFFIX_CHARS
set but without including&
the result isDIR/&
. WithZLE_SPACE_SUFFIX_CHARS
set to include&
the result isDIR &
.Note that certain completions may provide their own suffix removal or replacement behaviour which overrides the values described here.