From 33743922eb9386a81cc988bbf032bff44e95c128 Mon Sep 17 00:00:00 2001 From: Joshua Wood Date: Mon, 10 Oct 2022 21:56:13 -0400 Subject: [PATCH] Add support for multi-vterm --- CHANGELOG.develop | 1 + layers/+tools/shell/README.org | 13 +++++++++++++ layers/+tools/shell/funcs.el | 6 ++++++ layers/+tools/shell/packages.el | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 93e5d0145..8be0e5cf8 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -3560,6 +3560,7 @@ files (thanks to Daniel Nicolai) - function: =spacemacs/make-variable-layout-local= (thanks to JAremko and duianto) - Better keybindings for ~ESC~ and ~RET~ in vterm =evil-normal-state= (thanks to kenkangxgwe) +- Added support for multi-vterm as default terminal option **** Shell Scripts - Added new company-shell environment variable backend (thanks to Alexander-Miller) diff --git a/layers/+tools/shell/README.org b/layers/+tools/shell/README.org index 52c177983..12e251eaf 100644 --- a/layers/+tools/shell/README.org +++ b/layers/+tools/shell/README.org @@ -35,6 +35,7 @@ - [[#multi-term][Multi-term]] - [[#eshell-1][Eshell]] - [[#vterm][vterm]] + - [[#multi-vterm][Multi-vterm]] * Description This layer configures the various shells available in Emacs. @@ -118,6 +119,7 @@ to the following variables: - =term= - =ansi-term= (default on Linux/macOS) - =multi-term= +- =multi-vterm= - =vterm= #+BEGIN_SRC emacs-lisp @@ -294,6 +296,7 @@ Some advanced configuration is setup for =eshell= in this layer: | ~SPC a t s e~ | Toggle pop-shell with =eshell= | | ~SPC a t s i~ | Toggle pop-shell with =shell= | | ~SPC a t s m~ | Toggle pop-shell with =multi-term= | +| ~SPC a t s M~ | Toggle pop-shell with =multi-vterm= | | ~SPC a t s t~ | Toggle pop-shell with =ansi-term= | | ~SPC a t s T~ | Toggle pop-shell with =term= | | ~SPC a t s v~ | Toggle pop-shell with =vterm= | @@ -324,6 +327,7 @@ in the current buffer instead of a popup. | ~SPC m n~ | go to next multi-term | | ~SPC m N~ or ~SPC m p~ | go to previous multi-term | + ** Eshell | Key binding | Description | @@ -346,3 +350,12 @@ For example with bash (shell :variables spacemacs-vterm-history-file-location "~/.bash_history") #+END_SRC + +** Multi-vterm + +| Key binding | Description | +|------------------------+----------------------------| +| ~SPC m c~ | create a new multi-vterm | +| ~SPC m n~ | go to next multi-vterm | +| ~SPC m N~ or ~SPC m p~ | go to previous multi-vterm | +| ~SPC m r~ | rename vterm buffer | diff --git a/layers/+tools/shell/funcs.el b/layers/+tools/shell/funcs.el index f6c4f1e0c..bce207c98 100644 --- a/layers/+tools/shell/funcs.el +++ b/layers/+tools/shell/funcs.el @@ -75,6 +75,7 @@ Additionally changes to working directory when the value of `shell-pop-autocd-to-working-dir' is non-nil (default)." (interactive) (let ((shell (cl-case shell-default-shell + ('multi-vterm 'multivterm) ('multi-term 'multiterm) ('shell 'inferior-shell) (t shell-default-shell)))) @@ -241,6 +242,11 @@ is achieved by adding the relevant text properties." (interactive) (multi-term)) +(defun multivterm (&optional ARG) + "Wrapper to be able to call multi-vterm from shell-pop" + (interactive) + (multi-vterm)) + (defun inferior-shell (&optional ARG) "Wrapper to open shell in current window" (interactive) diff --git a/layers/+tools/shell/packages.el b/layers/+tools/shell/packages.el index a73944492..e7f265a1f 100644 --- a/layers/+tools/shell/packages.el +++ b/layers/+tools/shell/packages.el @@ -43,6 +43,7 @@ terminal-here vi-tilde-fringe window-purpose + (multi-vterm :toggle (not (spacemacs/system-is-mswindows))) (vterm :toggle (not (spacemacs/system-is-mswindows))))) @@ -368,6 +369,25 @@ (with-eval-after-load 'centered-cursor-mode (add-hook 'vterm-mode-hook 'spacemacs//inhibit-global-centered-cursor-mode))))) +(defun shell/init-multi-vterm () + (use-package multi-vterm + :defer t + :init + (progn + (make-shell-pop-command "multivterm" multivterm) + (spacemacs/set-leader-keys "atsM" 'spacemacs/shell-pop-multivterm) + (spacemacs/register-repl 'multi-vterm 'multi-vterm)) + :config + (progn + (setq vterm-shell shell-default-term-shell) + ;; multi-term commands to create terminals and move through them. + (spacemacs/set-leader-keys-for-major-mode 'vterm-mode + "c" 'multi-vterm + "n" 'multi-vterm-next + "N" 'multi-vterm-prev + "p" 'multi-vterm-prev + "r" 'multi-vterm-rename-buffer)))) + (defun shell/post-init-window-purpose () (purpose-set-extension-configuration :shell-layer