Skip to content

Commit

Permalink
Make shell-pop not prevent eshell to write history
Browse files Browse the repository at this point in the history
this is a workaround as the upstream issue is not
solved yet.

See #8538
  • Loading branch information
smile13241324 committed Sep 3, 2024
1 parent 648c74e commit edbd690
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions layers/+tools/shell/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ is achieved by adding the relevant text properties."
(spacemacs/set-leader-keys-for-major-mode 'eshell-mode
"H" 'spacemacs/helm-eshell-history)
(define-key eshell-mode-map
(kbd "M-l") 'spacemacs/helm-eshell-history))
(kbd "M-l") 'spacemacs/helm-eshell-history))

(defun spacemacs/ivy-eshell-history ()
(interactive)
Expand Down Expand Up @@ -283,8 +283,8 @@ tries to restore a dead buffer or window."
(interactive)
(cl-assert (string-equal mode-name "VTerm") nil "Not in VTerm mode")
(helm :sources (helm-build-sync-source "Bash history"
:candidates (spacemacs//vterm-make-history-candidates)
:action #'vterm-send-string)
:candidates (spacemacs//vterm-make-history-candidates)
:action #'vterm-send-string)
:buffer "*helm-bash-history*"
:candidate-number-limit 10000))

Expand All @@ -307,3 +307,11 @@ tries to restore a dead buffer or window."
(define-key mode-map (kbd "M-r") 'spacemacs/helm-vterm-search-history))
((configuration-layer/layer-used-p 'ivy)
(define-key mode-map (kbd "M-r") 'spacemacs/counsel-vterm-search-history))))

(defun spacemacs/shell-pop-with-eshell-history-write (orig-fun &rest args)
"Make sure that the eshell history is written before the window is closed."
(unless (one-window-p)
(when (string= shell-pop-internal-mode "eshell")
(eshell-write-history)
(eshell-write-last-dir-ring)
(apply orig-fun args))))
5 changes: 5 additions & 0 deletions layers/+tools/shell/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
shell-pop-window-size shell-default-height
shell-pop-term-shell shell-default-term-shell
shell-pop-full-span shell-default-full-span)

;; Make sure that eshell history is written before the window is closed
;; see https://github.com/kyagi/shell-pop-el/issues/66
(advice-add 'shell-pop--kill-and-delete-window :around #'spacemacs/shell-pop-with-eshell-history-write)

(make-shell-pop-command "eshell" eshell)
(make-shell-pop-command "term" term shell-pop-term-shell)
(make-shell-pop-command "ansi-term" ansi-term shell-pop-term-shell)
Expand Down

0 comments on commit edbd690

Please sign in to comment.