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


当前回答

为了快速清除单个tmux窗格,你可以设置一个别名…

# Tmux Clear pane
alias tc='clear; tmux clear-history; clear'

其他回答

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

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

这甚至适用于MySQL shell。

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

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

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

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

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

Ctrl-L在控制台应用程序中用于重绘屏幕。我发现当绑定到send-keys -R时,它会导致方向键在某些应用程序(如vim, mc)中不再正常工作。

为了在控制台应用程序中保留重绘功能,我使用了:

bind-key -n C-l if-shell -F '#{alternate_on}' 'send-keys C-l' 'send-keys -R C-l; clear-history'

这需要打开tmux选项的备用屏幕(默认情况下是这样)。

如果你在OSX上用Iterm挣扎:

如果使用clear清除屏幕,可以检查是否设置了TMUX,并相应地创建别名。

把这个放在你的。bashrc中:

if [[ $TMUX ]]; then
  alias clear='clear && tmux clear-history'
fi