On 08/02/2011 04:34 PM, Mikael Magnusson wrote: > On 2 August 2011 16:20, Pascal Wittmann <PascalWittmann@xxxxxxx> wrote: >> Hi, >> >> I'm trying to build something like this: >> >> function do-something() { >> zle beginning-of-line >> zle -U "something" >> zle end-of-line >> } >> zle -N do-something >> bindkey "^[i]" do-something > > You can modify the buffer directly via the BUFFER variable, so you > could just say BUFFER="something $BUFFER" and it should do what you > want. buffer. > Ok, that would work in this simple example. But actually I want to do some more stuff (the code above was just a minimal working example), here is the function: 9 replace-pacman-command() { 10 if [[ $LBUFFER = "pacman"* ]]; then 11 zle beginning-of-line 12 zle forward-word 13 zle delete-word 14 zle -U -- $@ 15 zle end-of-line 16 fi 17 } 18 19 replace-pacman-command-insert() { 20 replace-pacman-command "-S" 21 } 22 23 zle -N replace-pacman-command-insert 24 bindkey "^[i" replace-pacman-command-insert I think doing this directly via BUFFER gets quickly unreadable.
Attachment:
signature.asc
Description: OpenPGP digital signature