home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5772757557d70f2a03afe31cd335bd883d1812f7
parent d092500244798b7ffda3693e145c005b618d20d5
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Wed, 22 Jul 2020 18:32:47 +0200

tools/emacs: add a "main" vterm toggle

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mtools/emacs/config/config-shells.el | 26++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/tools/emacs/config/config-shells.el b/tools/emacs/config/config-shells.el @@ -254,9 +254,31 @@ using either KUBECONFIG or ~/.kube/config" (setq compilation-environment '("TERM=xterm-256color"))) (use-package vterm - :commands (vterm) + :commands (vterm vde/vterm-toggle) + :bind ("C-c t t" . vde/vterm-toggle) :custom - (vterm-kill-buffer-on-exit t)) + (vterm-kill-buffer-on-exit t) + :config + (defun vde/vterm-toggle () + "Toggle between the main vterm buffer and the current buffer. +If you are in a vterm buffer, switch the window configuration +back to your code buffers. Otherwise, create at least one vterm +buffer if it doesn't exist already, and switch to it. On every +toggle, the current window configuration is saved in a register." + (interactive) + (if (eq major-mode 'vterm-mode) + (jump-to-register ?W) + ;; Save current window config and jump to shell + (window-configuration-to-register ?W) + (condition-case nil + (jump-to-register ?Z) + (error + (vterm) + (when (= (length (window-list)) 2) + (other-window 1) + (vterm 1) + (other-window 1)))) + (window-configuration-to-register ?Z)))) ;; for fish in ansi-term (add-hook 'term-mode-hook 'toggle-truncate-lines)