【问题标题】:tmux: list command-prompt history?tmux:列出命令提示符历史?
【发布时间】:2017-06-25 11:08:07
【问题描述】:

我知道您可以逐行滚动浏览 tmux 命令提示历史记录(C-b :,然后箭头穿过它们)。

我正在寻找一种方法来查看该历史记录中最后 N 个命令的列表,但我没有找到一种方法来执行此操作。

有可能吗?

【问题讨论】:

标签: linux terminal command history tmux


【解决方案1】:

我不认为没有设置history-file设置(Can tmux save commands to a file, like .bash_history?)就可以做到这一点

.tmux.conf 中添加一行

set -g history-file ~/.tmux_history

设置后,您可以使用标准文件读取程序来获取Nth 行。例如:

tail -n N ~/.tmux_history | head -n 1

N 是您的行号。

【讨论】:

  • 只有当我输入-s选项时它才有效:set -sg history-file ~/.tmux_history
  • 未设置的历史记录存放在哪里?
  • @NikhilCSB 来自文档history-file path If not empty, a file to which tmux will write command prompt history on exit and load it from on start. 因此,当您的服务器处于活动状态时,历史记录可用,而在您关闭它后,历史记录将被删除。或者您可以将history-file 设置在某个位置,您可以使用tmux show-option -g history-file 进行检查
猜你喜欢
  • 2022-01-03
  • 1970-01-01
  • 1970-01-01
  • 2011-08-09
  • 2014-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多