2015-11-17 02:07:24 -05:00
|
|
|
;;; defuns-tmux.el
|
|
|
|
|
2015-12-09 01:17:08 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun tmux (command &optional run)
|
|
|
|
(shell-command (format (concat "tmux send-keys " (if run "C-u %s Enter" "%s"))
|
|
|
|
(shell-quote-argument command))))
|
2015-11-17 02:07:24 -05:00
|
|
|
|
|
|
|
(evil-define-interactive-code "<term>"
|
|
|
|
"Ex tmux argument (a mix between <sh> <f> and <fsh>)"
|
|
|
|
:ex-arg shell
|
|
|
|
(list (when (evil-ex-p) (evil-ex-file-arg))))
|
|
|
|
|
2015-12-09 01:17:08 -05:00
|
|
|
;;;###autoload (autoload 'narf:tmux-cd "defuns-term" nil t)
|
|
|
|
(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)
|
2015-11-17 02:07:24 -05:00
|
|
|
"Sends input to tmux. Use `bang' to append to tmux"
|
2015-12-09 01:17:08 -05:00
|
|
|
:type inclusive
|
|
|
|
:repeat t
|
|
|
|
(interactive "<r><term><!>")
|
|
|
|
(if (not 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"))))
|
|
|
|
|
2015-12-10 22:02:15 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun narf/tmux-vsplit-window ()
|
|
|
|
(interactive)
|
|
|
|
(narf/tmux-split-window t))
|
|
|
|
|
2015-12-09 01:17:08 -05:00
|
|
|
;;;###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)))
|
2015-11-17 02:07:24 -05:00
|
|
|
|
|
|
|
(provide 'defuns-tmux)
|
|
|
|
;;; defuns-tmux.el ends here
|