Saturday, 9 September 2017

using custom command from old .inputrc in zsh?


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.



Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...