Skip to content

Instantly share code, notes, and snippets.

@zw963
Created February 19, 2022 16:51
Show Gist options
  • Save zw963/c64b7519e0f45df161a9a4c532532281 to your computer and use it in GitHub Desktop.
Save zw963/c64b7519e0f45df161a9a4c532532281 to your computer and use it in GitHub Desktop.
(require 'multi-vterm)
(defun toggle-drop-down-term ()
"Open a drop-down terminal in the same directory as the current file."
(interactive)
(require 'multi-vterm)
(let ((win (get-local-window-for-buffer-name "*vterminal")))
(if win
(delete-window win)
(let ((vterm-buffer
(or
(get-local-buffer-for-buffer-name "*vterminal")
(get-buffer-create (multi-vterm-get-buffer))
)))
(unless (derived-mode-p 'vterm-mode)
(setq multi-vterm-buffer-list (nconc multi-vterm-buffer-list (list vterm-buffer)))
(set-buffer vterm-buffer)
(multi-vterm-internal)
)
(setq win
(display-buffer-in-side-window
vterm-buffer
'((side . top)
;; (dedicated . t)
)))
(select-window win)))))
(add-hook 'vterm-mode-hook (lambda ()
(define-key vterm-mode-map (kbd "M-9") 'multi-vterm-prev)
(define-key vterm-mode-map (kbd "M-0") 'multi-vterm-next)
(define-key vterm-mode-map [(control x) (\2)] 'split-window-below-then-switch-to-new-vterm)
(define-key vterm-mode-map [(control x) (\3)] 'split-window-right-then-switch-to-new-vterm)
(define-key vterm-mode-map [(shift control t)] 'multi-vterm)
(define-key vterm-mode-map [(shift space)] 'multi-vterm-dedicated-toggle)
))
(defun split-window-below-then-switch-to-new-vterm (&optional size)
(interactive)
(split-window-below size)
(other-window 1)
(multi-vterm)
)
(defun split-window-right-then-switch-to-new-vterm (&optional size)
(interactive)
(split-window-right size) (other-window 1) (multi-vterm))
(provide 'multi-vterm_init)
;;; multi-vterm_init.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment