Unix Subshell从父bash继承命令历史记录 [英] Unix Subshell inheriting the command history from parent bash
本文介绍了Unix Subshell从父bash继承命令历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一系列python工具,它们产生了新的bash会话.我希望这些单独的子shell继承父级的命令历史记录.我已经尝试过:
I have written a series of python tools that spawn new bash sessions. I am want those individual subshells to inherit the command history of the parent. I have tried:
shopt -s histappend
PROMPT_COMMAND="history -an;$PROMPT_COMMAND"
.bash_profile
中的
.但这并没有给我我所需要的.我已经看到了.我的工具使用:
in the .bash_profile
. But it didn't give me what I need. I have seen this done. My tool uses:
os.system('bash')
产生一个子进程.
有什么想法吗?更好的方法?
Thoughts? better way?
推荐答案
取决于您的操作系统,.bash_profile
只能由登录Shell执行,而.bashrc
则用于非登录Shell.
Depending on your OS, .bash_profile
may only be executed by login shells, while .bashrc
is executed for non-login shells.
所以请尝试
shopt -s histappend
PROMPT_COMMAND="history -a; history -n"
.bashrc
中,而不是在.bash_profile
中.
这篇关于Unix Subshell从父bash继承命令历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文