我想清除特定tmux窗格中的所有滚动历史。
当前回答
为什么不呢?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。
如果你在OSX上用Iterm挣扎:
经过大量的调查和时间。我已经在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
为什么不呢?bind -n C-l send-keys C-l
如果您希望完全清除窗格,另一种选择是暂时将窗格调整为一行,清除历史记录,然后将其调整回来。这应该可以用一个tmux命令链无闪烁地工作。其优点是无论窗格中运行的是什么程序,它都可以正常工作。当然,这使得shell脚本逻辑更加复杂。
bind-key -n F11 run "
if [[ #{window_panes} == "1" ]] ; then
tmux send-keys C-l; sleep 0.1 ; tmux clear-history ;
else
restored_height=$((#{pane_height} + #{pane_at_bottom}));
tmux resize-pane -y 1 \\; clear-history \\; resize-pane -y \${restored_height} ;
fi
"
推荐文章
- 如何从终端/命令行调用VS代码编辑器
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- “你有邮件”的消息在终端,os X
- Tmux:如何找到当前运行的Tmux版本?
- 如何使制表符4个空间而不是8个空间在纳米?
- 如何强制从另一个SSH会话分离屏幕?
- 如何从终端机发送电子邮件?
- 我如何重命名一个窗格在tmux?
- Git显示“警告:永久添加到已知主机列表”
- Docker- compose无法连接到Docker Daemon
- 如何复制文件跨计算机使用SSH和MAC OS X终端
- 崇高的文本从命令行
- Git bash错误:无法fork子进程:没有可用的终端(-1)
- 使用grep删除空行
- Git在终端提交时打开VIM,但无法返回终端