zsh: SHARE_HISTORY или INC_APPEND_HISTORY прерывает EXTENDED_HISTORY

zfs 0.7.9 ahora está disponible en los repositorios que solucionan el problema.

2
08.10.2017, 13:04
2 ответа

Я протестировал несколько способов обмена расширенной историей между несколькими сеансами терминала, и это единственный способ, который работает безупречно:

setopt extendedhistory incappendhistorytime
autoload -Uz add-zsh-hook

import-history() {
  # Pop the last history list, so we don't grow the history stack endlessly
  fc -P

  # Initialize a new history list from $HISTFILE (and push it onto the 
  # history stack).
  fc -p $HISTFILE
}

# Import the history at the start of each new prompt.
add-zsh-hook precmd import-history

Теперь все, что вам нужно сделать, чтобы синхронизировать вашу историю в любой терминальной сессии, это нажать Enter.

1
26.12.2020, 18:48

Единственный вариант, который вам нужен, этоSHARE_HISTORY

Вот видео работы с общей историей

А вот документация ссылка + цитата

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’.

0
26.05.2021, 21:05

Теги

Похожие вопросы