mik*_*ers 25 bash history byobu
我广泛使用这些功能来浏览终端中的命令历史记录;我想知道是否还有某种方法可以导航命令输出历史记录?(除了保持大的 histsize 并依靠 pgup 键)
我不能只是“重新运行命令”,因为在我的特定情况下,命令的来源会发生变化;我经常需要回顾以前更改的输出。
欢迎黑客。
谢谢!
2010年编辑:
我给了 'tee' 功劳;在其他地方记录会话的所有方法中,它是最广泛适用的(即它是 gnu coreutils 的一部分,并且不需要特定的 shell 或实用程序即可工作)。这不是我真正要寻找的东西,但我意识到这样的东西并不存在。
我能想到的最接近的近似方法是使用类似screen
(byobu/tmux) 的东西记录到文件,并编写(和键绑定)一个自定义命令来页面/搜索该日志文件(想想less
按提示而不是屏幕进行分页)。谢谢大家。
2012年编辑:
@Dustin Kirkland 的回答显然是最好的,至少一般来说是这样;终端的回滚缓冲区是导航命令输出历史记录的侵入性最小的方式。Byobu 似乎保存了大量的默认历史记录行数(10K;tmux 有 2K,GNU screen 100),并且它允许正则表达式搜索(粗略的观察表明 GNU screen 没有回滚搜索,而 tmux 只有纯文本搜索)。
screen
可以设置为日志输出。
在正在运行的screen
会话中启动它的一种方法是按Ctrl- a,然后按:,然后输入log
。
来自man screen
:
log [on|off]
Start/stop writing output of the current window to a file "screenlog.n" in the
window's default directory, where n is the number of the current window.
This filename can be changed with the `logfile' command. If no parameter is
given, the state of logging is toggled. The session log is appended to the
previous contents of the file if it already exists. The current contents and
the contents of the scrollback history are not included in the session log.
Default is `off'.
logfile filename
logfile flush secs
Defines the name the log files will get. The default is "screenlog.%n". The
second form changes the number of seconds screen will wait before flushing the
logfile buffer to the file-system. The default value is 10 seconds.
Run Code Online (Sandbox Code Playgroud)