dotfiles/emacs/.emacs.d/config/init-vterm.el

35 lines
1.3 KiB
EmacsLisp

(use-package vterm
:commands vterm
:init
(defun project-vterm ()
(interactive)
(if (projectile-project-root)
(call-interactively #'projectile-run-vterm)
(call-interactively #'vterm)))
:config
(evil-collection-vterm-setup)
(general-def 'insert vterm-mode-map "C-<escape>" #'vterm-send-escape)
;; 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 (and dir (eq major-mode 'vterm-mode))
(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
(vterm-environment '("TYPEWRITTEN_CURSOR=terminal"))
(vterm-ignore-blink-cursor t)
(vterm-eval-cmds '(("find-file" find-file)
("message" message)
("vterm-clear-scrollback" vterm-clear-scrollback)
("man" man)
("ediff" ediff))))
(provide 'init-vterm)