Skip to content

Commit 67d1dbd

Browse files
committed
feat: add vterm project shell
1 parent ba69e13 commit 67d1dbd

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

README.org

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ from: https://github.com/doomemacs/doomemacs/blob/master/lisp/doom-start.el
454454

455455
;; 数据目录
456456
(if sys-is-windows
457-
(defconst my-data-dir (expand-file-name "D:/Data"))
457+
(defconst my-data-dir (expand-file-name "D:/BaiduSyncdisk"))
458458
(if sys-is-wsl2
459-
(defconst my-data-dir (expand-file-name "/mnt/d/Data"))
460-
(defconst my-data-dir (expand-file-name "~/Data"))))
459+
(defconst my-data-dir (expand-file-name "/mnt/d/BaiduSyncdisk"))
460+
(defconst my-data-dir (expand-file-name "~/BaiduSyncdisk"))))
461461

462462
;; 笔记目录
463463
(defconst my-notes-dir (expand-file-name "Notes" my-data-dir))
@@ -1286,8 +1286,32 @@ ref:https://github.com/manateelazycat/toggle-one-window
12861286
#+begin_src elisp
12871287
(use-package vterm
12881288
:straight (vterm :type git :host github :repo "xhcoding/emacs-libvterm")
1289+
:preface
1290+
(defun my-vterm-setup()
1291+
(setq-local global-hl-line-mode nil)
1292+
(meow-mode -1))
1293+
:hook (vterm-mode . my-vterm-setup)
12891294
:config
1290-
(setq vterm-shell "pwsh.exe"))
1295+
(setq vterm-shell "pwsh.exe")
1296+
(defun my-project-shell ()
1297+
"Start an inferior shell in the current project's root directory.
1298+
If a buffer already exists for running a shell in the project's root,
1299+
switch to it. Otherwise, create a new shell buffer.
1300+
With \\[universal-argument] prefix arg, create a new inferior shell buffer even
1301+
if one already exists."
1302+
(interactive)
1303+
(require 'comint)
1304+
(let* ((default-directory (project-root (project-current t)))
1305+
(default-project-shell-name (project-prefixed-buffer-name "shell"))
1306+
(shell-buffer (get-buffer default-project-shell-name)))
1307+
(if (and shell-buffer (not current-prefix-arg))
1308+
(if (comint-check-proc shell-buffer)
1309+
(pop-to-buffer shell-buffer (bound-and-true-p display-comint-buffer-action))
1310+
(vterm shell-buffer))
1311+
(vterm (generate-new-buffer-name default-project-shell-name)))))
1312+
1313+
(advice-add 'project-shell :override #'my-project-shell)
1314+
)
12911315
#+end_src
12921316
** fingertip 智能括号插入
12931317

0 commit comments

Comments
 (0)