履歴を動的にリンクするシェルはありますか?

履歴を動的にリンクするシェルはありますか?

記録がクラッシュした後も維持されるように、動的に記録を追加するシェルはありますか?

ベストアンサー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'.

おすすめ記事