MacOS – Terminal – Weird spaces included when typing fast

command linekeyboardmacosterminal

Whenever I want to use the pipe operator in the terminal, I get a weird kind of "bug":

The "bug" in the terminal

As is shown in the image above, I can type the exact same command twice and it will sometimes register it or sometimes include some spacing in the command, as can be seen in the error message. The only difference between the two commands was the speed I typed them, with fast typing the char sequence "| " (without the "") leading to the error.
I've checked in the terminal settings if this sequence somehow triggers a shortcut, but I did not find anything.

In case it matters, I'm using a swiss keyboard. The layout is as follows:

Swiss keyboard layout for OS X

To produce the "|" character, I press "alt + 7". Does anybody know what the cause of this problem is?

Best Answer

You aren't releasing the Alt key (aka Option) quickly enough after typing the "|", so you're getting Option-Space, which is a non-breaking space. This looks like a normal space but gets treated as part of the command name rather than as a separator. See this SuperUser question for some options to disable the Option-Space key combo.