News for hackers. Stuff that matters.
Re:Simple command-line snippet manager, written in Go by kovek on Monday March 13, 2017 @03:58PM (#13861764)
That's cool! I was thinking of doing something similar a few weeks ago. I settled on using tools I knew well to just achieve what I needed quickly. I use tmux and emacs. I run a tmux session with a window which has a top and bottom pane. Top pane shows a shell, and bottom pane shows emacs. Thanks to tmux, I can send keystrokes to a different pane. With emacs, I tell tmux to send the current line of characters to the top pane. In the emacs session, I have open a help.org file, where I organize some commands. For some reason, this worked with tmux 2.1 but not with tmux 2.3:

    (defun send-command-to-cli () (interactive)
      (let ((current 0)
        (the-command "")
        (start 0)
        (end 0))
        (setq current (point))
        (org-beginning-of-line)
        (setq start (point))
        (org-end-of-line)
        (setq end (point))
        (goto-char current)
        (setq the-command (concat
          "tmux send-keys -t top ' "
          (buffer-substring start end)
          " ' ; tmux send-keys -t top C-a ; tmux send-keys -t top '#'; tmux select-pane -t top; " ))
        (message the-command)
        (shell-command the-command)
    ))

There are no comments on this comment yet.