Add directory-change hook for vterm

This commit is contained in:
Jeremy Dormitzer 2021-02-22 09:43:04 -05:00
parent c4ebd88c52
commit 24ad9d622a
2 changed files with 15 additions and 0 deletions

View File

@ -6,6 +6,10 @@
(direnv-mode)
(add-hook 'eshell-mode-hook #'direnv-update-directory-environment)
(add-hook 'eshell-directory-change-hook
(lambda ()
(unless (file-remote-p default-directory)
(direnv-update-directory-environment))))
(add-hook 'vterm-directory-change-hook
(lambda ()
(unless (file-remote-p default-directory)
(direnv-update-directory-environment)))))

View File

@ -8,6 +8,17 @@
(call-interactively #'vterm)))
:config
(evil-collection-vterm-setup)
;; Add a hook when vterm changes the directory
(defvar vterm-directory-change-hook nil
"Hooks to be run after vterm changes the directory")
(defun vterm--set-directory (path)
"Set `default-directory' to PATH."
(let ((dir (vterm--get-directory path)))
(when dir
(setq default-directory dir)
(run-hooks 'vterm-directory-change-hook))))
(add-hook 'vterm-mode-hook #'hack-dir-local-variables-non-file-buffer)
(add-hook 'vterm-directory-change-hook #'hack-dir-local-variables-non-file-buffer)
:general
(leader-map "v" #'project-vterm)
:custom