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


当前回答

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

使用ctrl - l

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

其他回答

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

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

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

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

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

为什么不呢?bind -n C-l send-keys C-l

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选项的备用屏幕(默认情况下是这样)。

这里的每个答案都在谈论添加新的键绑定。

如果你只是偶尔想这样做,你根本不需要映射……

Prefix默认为<Ctrl-b>

只需在相关窗格中键入<prefix> +:,然后键入clear-history并按enter。

如果您在命令行上,可以在相关窗格中运行tmux clear-history,以达到同样的效果。

关于tmux的一个很酷的事情是,您可以像这样运行任何命令……或者像tmux命令一样在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