1

记录 GNU screen 中的历史命令

 2 years ago
source link: https://blog.yxwang.me/2010/03/keep-gnu-screen-history/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

记录 GNU screen 中的历史命令

Mon, Mar 1, 2010 • Tooling

GNU screen中执行的历史命令保存在内存中,默认情况下并不会像在bash中直接执行的命令一样保存在.bash_history中,这在某些场合下带来了一定的不便。

在superuser上看到一个解决方法,指定历史文件的读写方式为追加,并在每次命令行提示符显示的时候,自动更新bash的历史命令记录。要实现这个方法很简单,只要在.bashrc中加入下面两行代码即可

shopt -s histappend
export PROMPT_COMMAND="history -a; history -n"

另外如果之前设置过PROMPT_COMMAND的话,只要在history -a前加入$PROMPT_COMMAND; 就行了。

本作品采用知识共享署名-非商业性使用 3.0 版本许可协议进行许可,欢迎转载,演绎,但是必须保留本文的署名 zellux(包含链接),且不得用于商业目的。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK