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


当前回答

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

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

Prefix默认为<Ctrl-b>

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

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

关于tmux的一个很酷的事情是,您可以像这样运行任何命令……或者像tmux命令一样在shell/脚本中运行它们…或者为他们做一个快捷键。

其他回答

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

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

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

这甚至适用于MySQL shell。

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

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

Prefix默认为<Ctrl-b>

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

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

关于tmux的一个很酷的事情是,您可以像这样运行任何命令……或者像tmux命令一样在shell/脚本中运行它们…或者为他们做一个快捷键。

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

这一切是这样的:

cls

clear;
tmux clear-history;

经过大量的调查和时间。我已经在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