3

I would like to use the expansion mv 'foo bar' !#:1:s^\ ^-^ to produce the command mv 'foo bar' 'foo-bar'. However when I press the space bar, zsh assumes I've finished typing the expansion, leaving me with mv 'foo bar' !#:1:s^\ which yields mv 'foo bar' 'foobar'.

I can circumvent this behavior by typing mv 'foo bar' !#:1:s^\^-^ and then backtracking with the arrow keys to obtain mv 'foo bar' !#:1:s^\ ^-^, but that defeats the purpose.

How can I just turn off the expand-on-spacebar behavior? I suppose my desired behavior is to leave the command un-expanded until I press Enter. I didn't find anything on this in the manpage for zshexpn.

Edit: I've found that I can type mv 'foo bar' !{#:1:s^\ ^-^}, which holds off the expansion until the } is typed. But the question of how to prevent the expand-on-spacebar behavior stands.

3

It seems you have bound the space key to magic-space, because the introduction to zsh explains:

If you bind space to magic-space, then csh-style history expansion is done on the line whenever you press the space bar.

So, either remove the line

bindkey " " magic-space

from your config. Or (if you are using some pre-defined config files like d'oh-my-zsh) make sure that the following command is executed after all other key bindings:

bindkey " " self-insert
  • 1
    I use Prezto. It turns out this was set in the "editor" module, in line 271 of the file .zprezto/modules/editor/init.zsh. I created a new "personal" branch by doing cd ~/.zprezto && git checkout -b personal. I commented out the line and then git commit`-ed the change, so the original Prezto configuration stays untouched. – shadowtalker Jun 10 '15 at 19:53
  • Also, running bindkey with no arguments dumps the list of bound keys to stdout. – shadowtalker Jun 10 '15 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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