我想清除特定tmux窗格中的所有滚动历史。


当前回答

如果你在OSX上用Iterm挣扎:

其他回答

我发现使用send-keys - r有点慢-这里有另一种方法用一个命令清除屏幕和历史记录

bind-key C send-keys "clear && tmux clear-history" \; send-keys "Enter"  

嵌套tmux调用的使用更为明显

“clear”\;send-keys“Enter”\;clear-history

未能从历史记录中清除屏幕的当前文本- clear-history命令似乎在单独的线程中运行以发送密钥。

这个问题已经困扰我很久了。这是我能想到的最好的。把这个放到你的.tmux.conf文件中:

bind -n C-k clear-history

这将ctrl-k绑定到tmux clear-history命令。bind后的-n使您不必发出tmux命令前缀(默认情况下是ctrl-b)。我使用bash,所以ctrl-l已经相当于在命令行输入“clear”。使用这两个键,我得到了一个很好的ctrl-l, ctrl-k组合,它将所有滚动缓冲区移出屏幕(“clear”),然后删除所有历史(tmux“clear-history”命令)。

它不像Terminal、iTerm或Konsole的一键组合来清除,但它比一直输入清除历史记录要好得多。

发现这在TMUX 2.6中工作得最好,清除屏幕,滚动,但保持提示后显示。

使用ctrl - l

bind-key -n C-l send-keys C-l \; send-keys -R \; clear-history

如果你想结合CTRL-L加上clear-history,添加到你的~/.tmux.conf:

bind u send-keys C-l \; run-shell "sleep .3s" \; clear-history

这甚至适用于MySQL shell。

经过大量的调查和时间。我已经在zsh和terminal.app上找到了最适合我的方式

我使用前缀-c来清除屏幕和前缀-c来清除历史记录和滚动缓冲区,上面没有留下任何行,因为我发现它很烦人。

没有活力

# 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

在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