mirror of
https://github.com/larstvei/dot-emacs.git
synced 2024-11-26 07:28:31 +00:00
Spawn new vterms in vc-root-dir
This commit is contained in:
parent
470b6419b1
commit
a58bb9c81b
22
init.org
22
init.org
@ -1555,9 +1555,14 @@
|
|||||||
|
|
||||||
** vterm
|
** vterm
|
||||||
|
|
||||||
Inspired by [[https://github.com/torenord/.emacs.d][torenord]], I maintain quick access to shell buffers with bindings
|
vterm is a fully capable terminal emulator, and I use it exclusively.
|
||||||
~M-1~ to ~M-9~. In addition, the ~M-z~ toggles between the last visited
|
|
||||||
shell, and the last visited non-shell buffer.
|
Inspired by [[https://github.com/torenord/.emacs.d][torenord]], I maintain quick access to vterm buffers with bindings
|
||||||
|
~M-1~ to ~M-9~. In addition, the ~C-z~ toggles between the last visited vterm, and
|
||||||
|
the last visited non-vterm buffer.
|
||||||
|
|
||||||
|
Fresh vterm buffers spawns with the directory given by ~vc-root-dir~ if it
|
||||||
|
exists and ~default-directory~ otherwise.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
@ -1570,11 +1575,12 @@
|
|||||||
(defun toggle-vterm (&optional n)
|
(defun toggle-vterm (&optional n)
|
||||||
(interactive)
|
(interactive)
|
||||||
(setq vterms (seq-filter 'buffer-live-p vterms))
|
(setq vterms (seq-filter 'buffer-live-p vterms))
|
||||||
(cond ((numberp n) (push (vterm n) vterms))
|
(let ((default-directory (or (vc-root-dir) default-directory)))
|
||||||
((null vterms) (push (vterm 1) vterms))
|
(cond ((numberp n) (push (vterm n) vterms))
|
||||||
((seq-contains-p vterms (current-buffer))
|
((null vterms) (push (vterm 1) vterms))
|
||||||
(switch-to-buffer (car (seq-difference (buffer-list) vterms))))
|
((seq-contains-p vterms (current-buffer))
|
||||||
(t (switch-to-buffer (car (seq-intersection (buffer-list) vterms))))))
|
(switch-to-buffer (car (seq-difference (buffer-list) vterms))))
|
||||||
|
(t (switch-to-buffer (car (seq-intersection (buffer-list) vterms)))))))
|
||||||
|
|
||||||
:bind (:map custom-bindings-map
|
:bind (:map custom-bindings-map
|
||||||
("C-z" . toggle-vterm)
|
("C-z" . toggle-vterm)
|
||||||
|
Loading…
Reference in New Issue
Block a user