我正在尝试进行设置,zsh以便在不同zsh会话之间共享命令历史记录:
screen会话中我已经把这个 .zshrc
#To save every command before it is executed (this is different from bash's history -a solution):
setopt inc_append_history
#To retrieve the history file everytime history is called upon.
setopt share_history
Run Code Online (Sandbox Code Playgroud)
但这不起作用。
例如,我输入 1 command:gedit afile
然后我去 zsh 并输入history. 我没有看到gedit afile。
“setopt”的输出是
% setopt
nohistbeep
histexpiredupsfirst
histfindnodups
histignorealldups
histignoredups
histignorespace
histnostore
histreduceblanks
histsavenodups
histverify
incappendhistory
interactive
monitor
promptsubst
sharehistory
shinstdin
zle
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
Fra*_*sco 10
您的问题的简单答案是您需要设置share_history,您可以这样做:
setopt share_history
因为您显然已经这样做了(并且该选项实际上有效)。我建议你检查:
histignorespace它们会被忽略)$HISTFILE在所有 shell 中设置了相同的值?echo 123在 tab-1 中发出。转到选项卡 2,调用history。它在吗?(根据您的问题,不是)。现在发出,fc -R(意味着重新读取历史文件),然后history它现在在那里?如果没有,您可能还想在 tab-1 处调用fc -A(-A将强制将您的历史记录附加到文件中)以确保将历史记录写入文件。小智 10
按后尝试搜索enter。
我测试的是:
echo "something"enter,然后检查是否看到来自 shell 1 的命令。就我而言,在按下 之前我不会看到命令enter。
| 归档时间: |
|
| 查看次数: |
7246 次 |
| 最近记录: |