开发者

Zsh: how to see all buffers?

开发者 https://www.devze.com 2022-12-27 14:12 出处:网络
You can push thi开发者_开发技巧ngs to buffer with ^Q and pop them with ESC-g. Alt+x vi-set-buffer changes buffer somehow. How can I see all the buffers? They are probably some files to look at.^Q (and

You can push thi开发者_开发技巧ngs to buffer with ^Q and pop them with ESC-g. Alt+x vi-set-buffer changes buffer somehow. How can I see all the buffers? They are probably some files to look at.


^Q (and Esc-Q) and Esc-g work with an emacs buffer, so I don't think they interact with the vi buffers.

This works in emacs mode (set -o emacs):

function _showbuffers()
{
    local nl=$'\n' kr
    typeset -T kr KR $'\n'
    KR=($killring)
    typeset +g -a buffers
    buffers+="      Pre: ${PREBUFFER:-$nl}"
    buffers+="  Buffer: $BUFFER$nl"
    buffers+="     Cut: $CUTBUFFER$nl"
    buffers+="       L: $LBUFFER$nl"
    buffers+="       R: $RBUFFER$nl"
    buffers+="Killring:$nl$nl$kr"
    zle -M "$buffers"
}
zle -N showbuffers _showbuffers
bindkey "^[o" showbuffers

To demonstrate it, try each of these steps, pressing Alt-o (letter "O") or Esc-o after each one:

  • To show the cut buffer, type echo abc then press Ctrl-u
  • To show the kill ring (the previous cut buffer moves there), type echo def then press Ctrl-u (or Home Ctrl-K or Ctrl-X Ctrl-K)
  • To show the pre buffer, type echo 'ghi, press enter, type jkl'
  • Press enter to execute the previous command and clear the current buffer (don't forget to press Alt-o to see the change)
  • To show the L and R buffers, type echo "mno pqr" and press the left arrow a couple of times
0

精彩评论

暂无评论...
验证码 换一张
取 消