I'm using the menu select behaviour in zsh, which invokes a menu below the cursor where you can see the various possibilities. The .zshrc option i have set for this is:

zstyle ':completion:*' menu select=2

By default, pressing Return to select a possibility in this menu only completes the word — it does not actually send the command. For example, i might get a menu like this:

~ % cd de<TAB>
completing directory:
[Desktop/]  Development/

Pressing Return here will result in:

~ % cd Desktop/

I then have to press Return a second time to actually send the command.

I can modify this behaviour to make it so that pressing Return both selects the completion and sends the command by doing this:

bindkey -M menuselect '^M' .accept-line

However, there's a problem with this! Sometimes i need to complete a file or directory without sending the command. For example, i might need to do ln -s Desktop Desktop2 — with this bindkey behaviour, trying to complete Desktop will result in ln -s Desktop/ being sent as the command, and obviously i don't want that.

So — is there a way to make it so that only some commands let you press Return once (like cd), but all other commands require pressing it twice?

Cheers

edit: I should add that i'm aware that just pressing space will let me get on with the command, but it's a habit...

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.