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.

I used to have this in my .inputrc when I used bash but it doesn't work in ZSH because ZSH doesn't read the .inputrc (AFAIK):

$if Bash
  # Meta+O can be made to load the previous 
  # command and position the cursor for typing an option
  "\eo": "\C-p\C-a\ef "

It's the one thing I miss from my bash days. Is there a way to port this command to ZSH? I tried some bindkey shenanigans with little success.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

That's right, zsh has its own line editor (ZLE) and doesn't read readline's .inputrc.

Try:

# define widget function
function cursor-after-first-word {
    zle up-history
    zle beginning-of-line
    zle forward-word
    RBUFFER=" $RBUFFER"
}

# create widget from function
zle -N cursor-after-first-word

# bind widget to ESC-o
bindkey '^[o' cursor-after-first-word

See man zshzle about what else is possible.

share|improve this answer
1  
Using emacs-forward-word instead of forward-word would better match how forward-word works in bash (and Emacs). Or the asker might want to redefine M-f and use a direct translation: bindkey '^[f' emacs-forward-word; bindkey -s '^[o' '^p^a^[f ' –  Chris Johnsen May 4 '11 at 2:54

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.