aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/rul-init.d/vterm.el
diff options
context:
space:
mode:
authorRaul Benencia <rul@kalgan.cc>2023-07-28 11:27:12 -0700
committerRaul Benencia <rul@kalgan.cc>2023-07-28 11:27:12 -0700
commit3e37b0223acb57b22fb49feb35d8630b59e32377 (patch)
tree93b4b0f01f5875e47ccef34a55e542e6e10d2c96 /.emacs.d/rul-init.d/vterm.el
parent6e94ad0b922de3d515c58408a54e7833f11685ee (diff)
emacs: in vterm-mode, only choose vterm buffers
Diffstat (limited to '.emacs.d/rul-init.d/vterm.el')
-rw-r--r--.emacs.d/rul-init.d/vterm.el37
1 files changed, 36 insertions, 1 deletions
diff --git a/.emacs.d/rul-init.d/vterm.el b/.emacs.d/rul-init.d/vterm.el
index 54abbbf..28c54e9 100644
--- a/.emacs.d/rul-init.d/vterm.el
+++ b/.emacs.d/rul-init.d/vterm.el
@@ -3,4 +3,39 @@
:config
(setq
vterm-max-scrollback 100000
-))
+)
+
+(defvar vterm-source
+ `(:name "VTerm Buffer"
+ :category 'buffer
+ :narrow ?t
+ :face 'consult-buffer
+ :history 'buffer-name-history
+ :state #'consult--buffer-state
+ :new
+ (lambda (name)
+ (with-current-buffer (get-buffer-create name)
+ (insert "#+title: " name "\n\n")
+ (vterm)
+ (consult--buffer-action (current-buffer))))
+ :items
+ (lambda ()
+ (mapcar #'buffer-name
+ (seq-filter
+ (lambda (x)
+ (eq (buffer-local-value 'major-mode x) 'vterm-mode))
+ (buffer-list))))))
+
+(add-to-list 'consult-buffer-sources 'vterm-source 'append)
+
+(setq consult-vterm-buffer-sources
+ (list
+ `(:hidden nil :narrow ?v ,@vterm-source)))
+
+(defun consult-vterm-buffer ()
+ "Switch to a vterm buffer"
+ (interactive)
+ (consult-buffer consult-vterm-buffer-sources))
+
+(bind-key "C-x b" 'consult-vterm-buffer vterm-mode-map)
+)
nihil fit ex nihilo