Challenge: Have local files in a developer setup for quick searching of a large tree of code, but mirror them to a remote test server any time they are edited, since your local development platform is not your test platform.
Solution: vim post hooks! Note that this is a work in progress.
/usr/bin/vim_mirror.py:
#!/usr/bin/python
import sys
import os
import subprocess
REMOTE_ROOT="user@host:/path/to/somedir"
if __name__ == "__main__":
if len(sys.argv) > 1:
tokens = sys.argv[1].split("/")
# as implemented this script will ONLY mirror all files rooted in "/basedev"
# to a given remote root... this will need to be tweaked for different
# developer setups in a future version of this script. Ideally it will take a list
if tokens[0] == '' and tokens[1] == "basedev":
local_file = sys.argv[1]
remote_part = "/".join(tokens[2:])
cmd = "rsync %s %s/%s" % (local_file, REMOTE_ROOT, remote_part)
print cmd
subprocess.call(cmd, shell=True)
.vimrc:
au BufWritePost * :!/usr/bin/vim_mirror.py %:p
Advertisement
I’ve been using MacFuse and SSHFS (sometimes with the MacFusion UI) to work off a remote dev server. It works pretty well on-site, but is a little slow over VPN for some things. I was just thinking today how some better caching (possibly even using rsync behind the scenes) would make it a whole lot nicer.
Yeah, definitely. Eclipse’s project, some tagging system, or some sort of copy of the tree just for searching (I don’t like Eclipse) seems like a decent solution too, as SSHfs for editing isn’t that bad. Though it would be better if SSHfs could just have a cache configured and do some clever things with inotify on the remote server and .. and … oh no, I think i just designed an enterprise code editing project
I started using Ack http://betterthangrep.com/ yesterday and that, though, is extra slow over SSHfs.