Other emamux.el send commands from Emacs to tmux

emamux lets you interact with tmux from Emacs.


We can use emamux to send either a single line or a region from Emacs to a tmux pane in an external terminal

The advantage is instead of copy and pasting code from emacs into a terminal we can send it with a single keyboard shortcut

Keyboard shortcut

The first time you run the keyboard shortcut you will be prompted to a tmux pane to send the command to

Code:
C-`

If you want to switch to another tmux pane prefix the keyboard shortcut with C-u

Code:
C-u C-`

add the following code to your init.el

Code:
;; ----------------------------------------------------------------------------------
;; emamux
;; ----------------------------------------------------------------------------------

(defun my/emamux-smart-send ()
  "Send active visual selection, or the current line if no selection."
  (interactive)
  (if (and (bound-and-true-p evil-mode) (evil-visual-state-p))
      (progn
        (emamux:send-region (region-beginning) (region-end))
        (evil-exit-visual-state))
    (emamux:send-region (line-beginning-position) (line-end-position))))

(use-package emamux
  :demand t
  :config
  ;; Global binding for normal/insert modes
  (global-set-key (kbd "C-`") 'my/emamux-smart-send)

  ;; Explicitly bind in Evil visual state so visual selections work
  (with-eval-after-load 'evil
    (define-key evil-visual-state-map (kbd "C-`") 'my/emamux-smart-send)))

emamux install and code


emamux github

 
Back
Top