Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I type a space followed by the pipe symbol '|' on the zsh command line, zsh eats the space, placing the pipe symbol directly up against the prior word. How do I stop it from doing that? I'm not sure about any possible stylistic conventions, but I like a space on both sides of the pipe symbol for readability. I'm using oh-my-zsh pretty much out of the box.

Solution

Based on mpy's answer below, I used the following solution:

By default, ZLE_REMOVE_SUFFIX_CHARS is undefined in zsh/ohmyzsh. When undefined, it acts as though it was:

ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'

I added the following definition to my ~/.zshrc:

ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&'

(all except pipe) and presto, perfect! problem gone.

share|improve this question
    
first re-try doing this using zsh -f (to skip loading your configuration). You'll notice that zsh won't do that anymore. Then, you'll have to dig (most likely) into oh-my-zsh to figure out how it is causing that ;-) –  Francisco Jun 30 '13 at 12:35

1 Answer 1

up vote 1 down vote accepted

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; if ZLE_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 is DIR&. With ZLE_REMOVE_SUFFIX_CHARS set but without including & the result is DIR/&. With ZLE_SPACE_SUFFIX_CHARS set to include & the result is DIR &.

Note that certain completions may provide their own suffix removal or replacement behaviour which overrides the values described here.

share|improve this answer
    
Yes, I hadn't noticed that until you mentioned it, but it only happens after a tab-completion, thanks for the answer, this gives me what I need :) –  scanny Jul 2 '13 at 8:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.