Giant's deep tmux monitor
This commit is contained in:
1 parent
b9913d968b
commit
80ca830bf8
1 file changed
+36
-1
+36
-1
@@ -551,14 +551,16 @@ EMACS-ALTERNATIVE is the Emacs equivalent (e.g., 'C-s')."
|
|||||||
"\\*Flycheck errors\\*"
|
"\\*Flycheck errors\\*"
|
||||||
help-mode
|
help-mode
|
||||||
compilation-mode
|
compilation-mode
|
||||||
|
"\\`\\*gd-tmux\\*\\'"
|
||||||
"eshell-popup\\*$"))
|
"eshell-popup\\*$"))
|
||||||
|
|
||||||
(defun my/popper-window-height (window)
|
(defun my/popper-window-height (window)
|
||||||
"Resize eshell popups to half the frame height; fit other popups."
|
"Resize terminal popups to half the frame height; fit other popups."
|
||||||
(let ((buffer (window-buffer window)))
|
(let ((buffer (window-buffer window)))
|
||||||
(if (with-current-buffer buffer
|
(if (with-current-buffer buffer
|
||||||
;; Eshell displays a new buffer before enabling `eshell-mode'.
|
;; Eshell displays a new buffer before enabling `eshell-mode'.
|
||||||
(or (derived-mode-p 'eshell-mode)
|
(or (derived-mode-p 'eshell-mode)
|
||||||
|
(equal (buffer-name) "*gd-tmux*")
|
||||||
(string-match-p "eshell-popup\\*$" (buffer-name))))
|
(string-match-p "eshell-popup\\*$" (buffer-name))))
|
||||||
;; A functional `window-height' action must resize the window.
|
;; A functional `window-height' action must resize the window.
|
||||||
(let ((height (/ (frame-height (window-frame window)) 2)))
|
(let ((height (/ (frame-height (window-frame window)) 2)))
|
||||||
@@ -1139,15 +1141,48 @@ any directory proffered by `consult-dir'."
|
|||||||
;;;; Eat
|
;;;; Eat
|
||||||
(use-package eat
|
(use-package eat
|
||||||
:ensure t
|
:ensure t
|
||||||
|
:bind (("C-o g" . my/gd-tmux-toggle))
|
||||||
:custom
|
:custom
|
||||||
(eat-term-name "xterm-256color")
|
(eat-term-name "xterm-256color")
|
||||||
:init
|
:init
|
||||||
|
(defun my/gd-tmux-toggle ()
|
||||||
|
"Show or hide the tmux terminal on gd.
|
||||||
|
Connect the Tubnix tunnel in WireGuard first. Hiding the popup keeps
|
||||||
|
SSH alive; opening it after SSH exits reconnects to the existing tmux
|
||||||
|
session. With multiple sessions, tmux chooses its default session."
|
||||||
|
(interactive)
|
||||||
|
(if-let* ((window (get-buffer-window "*gd-tmux*")))
|
||||||
|
(quit-window nil window)
|
||||||
|
(require 'eat)
|
||||||
|
;; Always launch local SSH, even when called from a TRAMP buffer.
|
||||||
|
(let* ((default-directory (expand-file-name "~/"))
|
||||||
|
(buffer (eat-make "gd-tmux" "ssh" nil
|
||||||
|
"-t" "-o" "ConnectTimeout=10"
|
||||||
|
"-o" "ServerAliveInterval=15"
|
||||||
|
"-o" "ServerAliveCountMax=3"
|
||||||
|
"gd" "tmux attach-session")))
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(use-local-map (copy-keymap (current-local-map)))
|
||||||
|
(local-set-key (kbd "q") #'quit-window)
|
||||||
|
;; Eat's input modes take precedence over the major-mode map.
|
||||||
|
(dolist (mode '(eat--semi-char-mode eat--char-mode))
|
||||||
|
(let ((map (make-sparse-keymap)))
|
||||||
|
(set-keymap-parent map (alist-get mode minor-mode-map-alist))
|
||||||
|
(define-key map (kbd "q") #'quit-window)
|
||||||
|
(setq-local minor-mode-overriding-map-alist
|
||||||
|
(cons (cons mode map)
|
||||||
|
(assq-delete-all
|
||||||
|
mode minor-mode-overriding-map-alist))))))
|
||||||
|
(pop-to-buffer buffer))))
|
||||||
|
|
||||||
(eval-after-load 'eshell #'eat-eshell-mode)
|
(eval-after-load 'eshell #'eat-eshell-mode)
|
||||||
(eval-after-load 'eshell #'eat-eshell-visual-command-mode)
|
(eval-after-load 'eshell #'eat-eshell-visual-command-mode)
|
||||||
:config
|
:config
|
||||||
(defun advise-eat-keymap (map)
|
(defun advise-eat-keymap (map)
|
||||||
(define-key map [?\C-o] nil)
|
(define-key map [?\C-o] nil)
|
||||||
(define-key map (vector meta-prefix-char ?`) nil)
|
(define-key map (vector meta-prefix-char ?`) nil)
|
||||||
|
;; Let Popper dismiss terminal windows without sending M-o remotely.
|
||||||
|
(define-key map (vector meta-prefix-char ?o) nil)
|
||||||
(define-key map [S-v] #'eat-yank))
|
(define-key map [S-v] #'eat-yank))
|
||||||
|
|
||||||
(define-advice eat-eshell-semi-char-mode
|
(define-advice eat-eshell-semi-char-mode
|
||||||
|
|||||||
Reference in new issue
Block a user