Skip to content

A bETTER way to paste from a tmux remote console to osx

I finally came up with the way I always wanted this to work. Here is my workflow:

1. I run a command in a tmux pane to copy the entire buffer history of that pane.
2. Sublime Text pops open with the text from that buffer, I can edit the text and copy whatever I need to share with others.

Prerequisites: have dropbox running on wherever tmux is running (yes dropbox does work without a gui).

1. First off, my tmux.conf:

bind-key p command-prompt -p ‘save to file:’ -I ‘~/Dropbox/tmux/tmux.history.txt’ ‘capture-pane -S -32768 ; save-buffer %1 ; delete-buffer’

2. Now let’s run a launchctl to monitor the folder and open it in sublime text. Change USERNAME to your username (I’ll fix that in 2.0).

vi ~/Library/LaunchAgents/tmux.plist

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN”
<plist version=”1.0″>
<string>Sublime Text</string>

3. launchctl load ~/Library/LaunchAgents/tmux.plist
4. Test it by launching tmux on your remote server, control-b -> p -> return
5. If everything went well, your sublime text should open with your tmux history automagically.
6. A nice trick to go to the bottom in sublime text command – <down arrow>

Post a Comment

You must be logged in to post a comment.