Descargo de responsabilidad: no uso eshell, así que tómalo con un grano de sal.
eshellparece llamar eshell-write-historypara escribir el historial, que toma un argumento opcional appendque por defecto es nil. Parece que este argumento no se utiliza eshellactualmente, pero parece funcionar (pasa el argumento a write-region, que se adjunta correctamente).
Hay un par de opciones aquí.
(setq eshell-save-history-on-exit nil)y llamate a eshell-write-historyti mismo
- Redefina
eshell-write-historypara satisfacer sus necesidades.
Personalmente, iría con 1.
Como ejemplo:
(setq eshell-save-history-on-exit nil)
(defun eshell-append-history ()
"Call `eshell-write-history' with the `append' parameter set to `t'."
(when eshell-history-ring
(let ((newest-cmd-ring (make-ring 1)))
(ring-insert newest-cmd-ring (car (ring-elements eshell-history-ring)))
(let ((eshell-history-ring newest-cmd-ring))
(eshell-write-history eshell-history-file-name t)))))
(add-hook eshell-pre-command-hook #'eshell-append-history)
Gracias a @ joseph-garvin por la eshell-append-historyfunción de trabajo corregida
Esto no se encarga de cargar dinámicamente los nuevos contenidos del historial en un shell (por ejemplo, ejecutar el comando Xen el shell A y hacer que aparezca en el historial en el shell B sin volver a cargar; como SHARE_HISTORY de zsh). No sé qué tan eficiente eshell-read-historyes, así que dudaría en ejecutarlo en un gancho.
También es posible que termine con entradas duplicadas con esta eshell-append-historyfunción. Es posible que deba hacer algunas travesuras borrando todas las entradas eshell-history-ring, excepto la más reciente , y luego restableciéndolas al valor anterior después de escribir el historial.
P.ej
(let ((old-ring (copy-list eshell-history-ring)))
(setq eshell-history-ring (list (car eshell-history-ring)))
; write
(setq eshell-history-ring old-ring))
eshell-exit-hooka cero, puesto que esto automáticamente se carga cuando se inicia eshell:(add-hook 'eshell-exit-hook 'eshell-write-history nil t). Configuré el gancho para que sea localmente nulo (es globalmente nulo por defecto):(add-hook 'eshell-mode-hook '(lambda () (setq eshell-exit-hook nil)))