<commit_before>;;; module-tmux.el

;; This library offers:
;;   + TODO An integration/abstraction layer to make it seem like tmux and emacs are one
;;     program.
;;   + TODO A way to manage tmux sessions and layouts from emacs; possibly trigger them
;;     depending on current project.

;;;###autoload
(defun tmux (command &optional modes)
  (let ((format
         (concat "tmux send-keys "
                 (if (or (eq modes t)
                         (eq modes 'clear)
                         (memq 'clear modes))
                     "C-u " "")
                 "%s"
                 (if (or (eq modes t)
                         (eq modes 'run)
                         (memq 'run modes))
                     " Enter" ""))))
    (shell-command (format format (shell-quote-argument command)))))

(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))))

;;;###autoload (autoload 'narf:tmux-cd "module-tmux" 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 "module-tmux" nil t)
(evil-define-operator narf:tmux (&optional command bang)
  "Sends input to tmux. Use `bang' to append to tmux"
  :type inclusive
  :repeat t
  (interactive "<term><!>")
  (if (not command)
      (os-switch-to-term)
    (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-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)))

;;;;;;;;;;

;; TODO
;; (defun narf/window (direction)
;;   )

(provide 'module-tmux)
;;; module-tmux.el ends here<commit_msg>tmux: repeat last command when no arguments given to :t<commit_after>;;; module-tmux.el

;; This library offers:
;;   + TODO An integration/abstraction layer to make it seem like tmux and emacs are one
;;     program.
;;   + TODO A way to manage tmux sessions and layouts from emacs; possibly trigger them
;;     depending on current project.

;;;###autoload
(defun tmux (command &optional modes)
  (let ((format
         (concat "tmux send-keys "
                 (if (or (eq modes t)
                         (eq modes 'clear)
                         (memq 'clear modes))
                     "C-u " "")
                 "%s"
                 (if (or (eq modes t)
                         (eq modes 'run)
                         (memq 'run modes))
                     " Enter" ""))))
    (shell-command (format format (shell-quote-argument command)))))

(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))))

;;;###autoload (autoload 'narf:tmux-cd "module-tmux" nil t)
(evil-define-command narf:tmux-cd (&optional bang)
  (interactive "<!>")
  (if bang
      (narf/tmux-cd-to-project)
    (narf/tmux-cd-to-here)))

(defvar narf-tmux-last-command nil "The last command sent to tmux")
;;;###autoload (autoload 'narf:tmux "module-tmux" nil t)
(evil-define-operator narf:tmux (&optional command bang)
  "Sends input to tmux. Use `bang' to append to tmux"
  :type inclusive
  (interactive "<term><!>")
  (unless command
    (setq command narf-tmux-last-command))
  (if (not command)
      (os-switch-to-term)
    (tmux command (not bang))
    (setq narf-tmux-last-command command)
    (when (evil-ex-p)
      (message "[Tmux] %s" command))))

;;;###autoload
(defun narf/tmux-new-window ()
  (interactive)
  (tmux "tmux new-window" t))

;;;###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 'module-tmux)
;;; module-tmux.el ends here
{'fraction_non_alphanumeric': 0.1630724497213472, 'fraction_numerical': 0.0, 'mean_word_length': 2.5494411006018916, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4855398', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1444, 'n_words': 396}