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”
“http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>FolderActions</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-a</string>
<string>Sublime Text</string>
<string>/Users/bsmith/Dropbox/tmux/tmux.history.txt</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/bsmith/Dropbox/tmux</string>
</array>
</dict>
</plist>
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