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

39 lines
1.4 KiB
EmacsLisp
Raw Normal View History

2021-04-05 14:46:49 +00:00
;; -*- lexical-binding: t; -*-
2021-02-21 13:20:05 +00:00
(use-package vterm
:commands vterm
:init
(defun project-vterm ()
(interactive)
(if (projectile-project-root)
(call-interactively #'projectile-run-vterm)
(call-interactively #'vterm)))
2021-02-21 21:09:28 +00:00
:config
(evil-collection-vterm-setup)
2021-03-08 22:35:03 +00:00
(general-def 'insert vterm-mode-map "C-<escape>" #'vterm-send-escape)
2021-02-22 14:43:04 +00:00
;; 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))
2021-02-22 14:43:04 +00:00
(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)
2021-02-21 13:20:05 +00:00
:general
2021-02-21 21:09:28 +00:00
(leader-map "v" #'project-vterm)
:custom
2021-03-19 18:29:13 +00:00
(vterm-max-scrollback 10000)
2021-02-21 21:09:28 +00:00
(vterm-environment '("TYPEWRITTEN_CURSOR=terminal"))
(vterm-ignore-blink-cursor t)
(vterm-eval-cmds '(("find-file" find-file)
("ff" find-file)
("message" message)
("vterm-clear-scrollback" vterm-clear-scrollback)
("man" man)
("ediff" ediff))))
2021-02-21 13:20:05 +00:00
(provide 'init-vterm)