我想清除特定tmux窗格中的所有滚动历史。
当前回答
经过大量的调查和时间。我已经在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
其他回答
如果你想结合CTRL-L加上clear-history,添加到你的~/.tmux.conf:
bind u send-keys C-l \; run-shell "sleep .3s" \; clear-history
这甚至适用于MySQL shell。
正如@juanpaco正确指出的那样,clear-history是清除滚动缓冲区的命令。 我还要补充一点,我喜欢在同一个命令中清除屏幕上的内容。 发出一个send-keys -R会重置(清除)屏幕,所以我在.tmux.conf中使用了下面的代码
-R \;clear-history
这将清除屏幕和滚动缓冲区。
如果使用clear清除屏幕,可以检查是否设置了TMUX,并相应地创建别名。
把这个放在你的。bashrc中:
if [[ $TMUX ]]; then
alias clear='clear && tmux clear-history'
fi
为什么不呢?bind -n C-l send-keys C-l
发现这在TMUX 2.6中工作得最好,清除屏幕,滚动,但保持提示后显示。
使用ctrl - l
bind-key -n C-l send-keys C-l \; send-keys -R \; clear-history
推荐文章
- 我如何重命名一个窗格在tmux?
- Git显示“警告:永久添加到已知主机列表”
- Docker- compose无法连接到Docker Daemon
- 如何复制文件跨计算机使用SSH和MAC OS X终端
- 崇高的文本从命令行
- Git bash错误:无法fork子进程:没有可用的终端(-1)
- 使用grep删除空行
- Git在终端提交时打开VIM,但无法返回终端
- 提交指定文件
- 如何在Mac上设置我的默认shell,例如Fish?
- 如何在Linux虚拟机的控制台中上下滚动
- 如何在终端中提高光标速度?
- 修改一个目录下所有文件和文件夹的权限为644/755
- 仅在文件不存在时才将行追加到文件中
- 如何清除tmux中的滚动缓冲区?