How can I clear scrollback buffer in Tmux?

前端 未结 13 2582
悲&欢浪女
悲&欢浪女 2020-12-12 09:10

FYI, I am using Tmux through the Mac OS X Terminal app.

13条回答
  •  旧巷少年郎
    2020-12-12 09:51

    After a lot of research and spending time. I have found the best way for me on zsh and terminal.app

    I am using prefix-c to clear the screen and prefix-C to clear the history and the scroll buffer and leaving no lines above because I find it annoying.

    Without Vim

    # clear screen
    bind c send-keys 'C-l'
    # clear screen and history
    bind C send-keys -R \; send-keys C-l \; clear-history \; send-keys
    

    With Vim

    # check if the pane is running vim
    is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
    
    # clear screen
    bind c if-shell "$is_vim" "send-keys c" "send-keys 'C-l'"
    # clear screen and history
    bind C send-keys -R \; send-keys C-l \; clear-history \; send-keys
    

提交回复
热议问题