I often need to keep several directories synchronized across two or three machines. I will periodically run
diff -qr local/path mounted/remote/path > diff-list.txt to get a list of what is different and what is only present on either machine. After this runs, my current workflow is to cleanup the "diff output" then set about doing manual comparisons between the local and remote files. I cannot fully automate the synchronization or "merge" operation; some files need to be different and will always show up as part of the diff. (That's OK.)
Here's a sample line from my diff file ...
Files /home/seokor/root/src/bin/pasteboard/test/sok-info/swap.c and /mnt/diakor/root/src/bin/pasteboard/test/sok-info/swap.c differ
The pain point is this: My current workflow has
diff-list.txt opened in VIM in one tmux window and a
vimdiff of the two files in question opened in another tmux window. I review the differences, resolve conflicts (merge, copy/replace, ignore, ... whatever). Then I quit the
vimdiff session, go back to tmux window 0, get the next pair of files, go back to tmux window 1, run
vimdiff on this new pair of files ... rinse and repeat.
I want to have this: A single VIM session with three panes: left is
diff-list.txt, middle and right are
vimdiff-ish. As I cursor up/down in the left-most pane (the listing), when I hit
<RETURN> (or some other mapping), I'd like the current line to be parsed (to extract the two file paths) and have the middle and right panes updated to open the two files then refresh the diff. Think of this as a "diff browser."
I've played a little bit with the idea and I managed to do this:
vim -O -c 'wincmd l | diffthis | wincmd l | diffthis | 2wincmd h' f1 f2 f3
Of course, files
f are just for experimenting, but
f1 would be
f3 would be pulled from the list's current line. (This test was to see if I could open VIM with three buffers and have only two of them operate as a
vimdiff. And it works.)
My question: Can this be done? Can a vimscript be written that is attached only to a specific buffer (in this case, the "diff listing" buffer on the left)? Can a vimscript, after parsing the buffer's line to extract file names, "push" those file names to the other two buffers (ostensibly closing the previous files and opening the new ones), then force a diff update?