我想清除特定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。

如果你在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命令似乎在单独的线程中运行以发送密钥。

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

把这个放在你的。bashrc中:

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

比大多数更简单的方法是,我只创建了一个名为cls的shell脚本,并在我想清除屏幕和滚动缓冲区时运行它。

这一切是这样的:

cls

clear;
tmux clear-history;