Redo tmux library + ex commands
This commit is contained in:
parent
ae391a3356
commit
4882df4847
2 changed files with 47 additions and 10 deletions
|
@ -1,21 +1,55 @@
|
||||||
;;; defuns-tmux.el
|
;;; defuns-tmux.el
|
||||||
|
|
||||||
(defun narf--send-to-tmux (command)
|
;;;###autoload
|
||||||
(shell-command (format "tmux send-keys %s" command)))
|
(defun tmux (command &optional run)
|
||||||
|
(shell-command (format (concat "tmux send-keys " (if run "C-u %s Enter" "%s"))
|
||||||
|
(shell-quote-argument command))))
|
||||||
|
|
||||||
(evil-define-interactive-code "<term>"
|
(evil-define-interactive-code "<term>"
|
||||||
"Ex tmux argument (a mix between <sh> <f> and <fsh>)"
|
"Ex tmux argument (a mix between <sh> <f> and <fsh>)"
|
||||||
:ex-arg shell
|
:ex-arg shell
|
||||||
(list (when (evil-ex-p) (evil-ex-file-arg))))
|
(list (when (evil-ex-p) (evil-ex-file-arg))))
|
||||||
|
|
||||||
;;;###autoload (autoload 'narf:send-to-tmux "defuns-term" nil t)
|
;;;###autoload (autoload 'narf:tmux-cd "defuns-term" nil t)
|
||||||
(evil-define-command narf:send-to-tmux (command &optional bang)
|
(evil-define-command narf:tmux-cd (&optional bang)
|
||||||
|
(interactive "<!>")
|
||||||
|
(if bang
|
||||||
|
(narf/tmux-cd-to-project)
|
||||||
|
(narf/tmux-cd-to-here)))
|
||||||
|
|
||||||
|
;;;###autoload (autoload 'narf:tmux "defuns-term" nil t)
|
||||||
|
(evil-define-operator narf:tmux (beg end &optional command bang)
|
||||||
"Sends input to tmux. Use `bang' to append to tmux"
|
"Sends input to tmux. Use `bang' to append to tmux"
|
||||||
(interactive "<term><!>")
|
:type inclusive
|
||||||
(narf--send-to-tmux (format (if bang "%s" "C-u %s Enter")
|
:repeat t
|
||||||
(shell-quote-argument command)))
|
(interactive "<r><term><!>")
|
||||||
(when (evil-ex-p)
|
(if (not command)
|
||||||
(message "[Tmux] %s" command)))
|
(os-switch-to-term)
|
||||||
|
(when (use-region-p)
|
||||||
|
(setq command (concat command (buffer-substring-no-properties beg end))))
|
||||||
|
(tmux command bang)
|
||||||
|
(when (evil-ex-p)
|
||||||
|
(message "[Tmux] %s" command))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/tmux-new-window ()
|
||||||
|
(interactive)
|
||||||
|
(tmux "tmux new-window" t))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/tmux-split-window (&optional vertical)
|
||||||
|
(interactive)
|
||||||
|
(tmux (concat "tmux split-window" (if vertical " -h"))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/tmux-cd-to-here (&optional dir)
|
||||||
|
(interactive)
|
||||||
|
(tmux (format "cd '%s'" (or dir default-directory))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun narf/tmux-cd-to-project ()
|
||||||
|
(interactive)
|
||||||
|
(narf/tmux-cd-to-here (narf/project-root)))
|
||||||
|
|
||||||
(provide 'defuns-tmux)
|
(provide 'defuns-tmux)
|
||||||
;;; defuns-tmux.el ends here
|
;;; defuns-tmux.el ends here
|
||||||
|
|
|
@ -47,7 +47,10 @@
|
||||||
(exmap "@" 'narf/evil-macro-on-all-lines)
|
(exmap "@" 'narf/evil-macro-on-all-lines)
|
||||||
|
|
||||||
(exmap "t[mux]" 'narf:send-to-tmux)
|
(exmap "t[mux]" 'narf:send-to-tmux)
|
||||||
(exmap "tcd" (λ (narf:send-to-tmux (format "cd '%s'" default-directory))))
|
(exmap "t[mux]w" 'narf/tmux-new-window)
|
||||||
|
(exmap "t[mux]s" 'narf/tmux-split-window)
|
||||||
|
(exmap "t[mux]v" (λ (narf/tmux-split-window t)))
|
||||||
|
(exmap "tcd" 'narf:tmux-cd)
|
||||||
|
|
||||||
(exmap "cont[act]" 'narf:org-crm-contact)
|
(exmap "cont[act]" 'narf:org-crm-contact)
|
||||||
(exmap "proj[ect]" 'narf:org-crm-project)
|
(exmap "proj[ect]" 'narf:org-crm-project)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue