- [Show pagesource]
- [Old revisions]
- [Move]
Make Zle act in the manner of many IRC clients by allowing the user to type something, press down arrow to get a blank input line, type something else and execute it, then press up twice and get what was typed previously (but not executed). From Bart;
First, a "fake-accept-line" to not really execute the command, but put it on the history. There are several different ways to do this with preexec hooks etc., but let's just do it the old-fashioned way:
fake-accept-line() {
if [[ -n "$BUFFER" ]];
then
print -S "$BUFFER"
fi
return 0
}
zle -N fake-accept-line
Next you want a function that does down-line-or-history unless there is nowhere to go (and no new line in a multi-line buffer), in which case it does fake-accept-line.
down-or-fake-accept-line() {
if (( HISTNO == HISTCMD )) && [[ "$RBUFFER" != *$'\n'* ]];
then
zle fake-accept-line
fi
zle .down-line-or-history "$@"
}
zle -N down-line-or-history down-or-fake-accept-line
to bind this to the existing key for down-line-or-history, or
bindkey '^[[B' down-or-fake-accept-line
that is if ^[[B is your terminal's down arrow.
zle/ircclientlikeinput.txt · Last modified: 2011/12/21 07:33 by milk



