기록을 동적으로 연결하는 쉘이 있습니까?

기록을 동적으로 연결하는 쉘이 있습니까?

기록이 충돌 후에도 유지되도록 동적으로 기록을 추가하는 쉘이 있습니까?

답변1

zsh에는 관련된 옵션이 많이 있습니다:

인용 매뉴얼(참조info zsh appendhistory):

APPEND_HISTORY <D>
     If this is set, zsh sessions will append their history list to the
     history file, rather than replace it.  Thus, multiple parallel zsh
     sessions will all have the new entries from their history lists
     added to the history file, in the order that they exit.  The file
     will still be periodically re-written to trim it when the number of
     lines grows 20% beyond the value specified by $SAVEHIST (see also
     the HIST_SAVE_BY_COPY option).

INC_APPEND_HISTORY
     This option works like APPEND_HISTORY except that new history lines
     are added to the $HISTFILE incrementally (as soon as they are
     entered), rather than waiting until the shell exits.  The file will
     still be periodically re-written to trim it when the number of
     lines grows 20% beyond the value specified by $SAVEHIST (see also
     the HIST_SAVE_BY_COPY option).

INC_APPEND_HISTORY_TIME
     This option is a variant of INC_APPEND_HISTORY in which, where
     possible, the history entry is written out to the file after the
     command is finished, so that the time taken by the command is
     recorded correctly in the history file in EXTENDED_HISTORY format.
     This means that the history entry will not be available immediately
     from other instances of the shell that are using the same history
     file.

     This option is only useful if INC_APPEND_HISTORY and SHARE_HISTORY
     are turned off.  The three options should be considered mutually
     exclusive.

SHARE_HISTORY <K>

     This option both imports new commands from the history file, and
     also causes your typed commands to be appended to the history file
     (the latter is like specifying INC_APPEND_HISTORY, which should be
     turned off if this option is in effect).  The history lines are
     also output with timestamps ala EXTENDED_HISTORY (which makes it
     easier to find the spot where we left off reading the file after it
     gets re-written).

     By default, history movement commands visit the imported lines as
     well as the local lines, but you can toggle this on and off with
     the set-local-history zle binding.  It is also possible to create a
     zle widget that will make some commands ignore imported commands,
     and some include them.

     If you find that you want more control over when commands get
     imported, you may wish to turn SHARE_HISTORY off,
     INC_APPEND_HISTORY or INC_APPEND_HISTORY_TIME (see above) on, and
     then manually import commands whenever you need them using 'fc
     -RI'.

답변2

bash는 작동합니다. PROMPT_COMMAND를 'history -a'로 설정(또는 포함)하면 됩니다. 자세한 내용은 "man bash"의 "history" 내장 명령과 PROMPT_COMMAND 변수를 참조하세요.

관련 정보