Created
July 30, 2012 00:35
-
-
Save letsspeak/3202943 to your computer and use it in GitHub Desktop.
immediately rsync when the file in specific directory was written by vim (final edition)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
rsync -av -e "ssh -p XXXX" $1 [email protected]:$2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autocmd! BufWritePost * call SyncCharag() | |
function! SyncCharag() | |
let local_directory = "/Users/eveningsun/rails/charag/" | |
let remote_directory = "/home/www/rails/charag/" | |
let local_fullpath = getcwd()."/".bufname("%") | |
if local_fullpath =~ "^".local_directory | |
let local_directory_len = strlen(local_directory) | |
let local_tofile_len = strlen(local_fullpath) - local_directory_len | |
let local_tofile = strpart(local_fullpath, local_directory_len, local_tofile_len) | |
let remote_fullpath = remote_directory.local_tofile | |
exec 'call system("$HOME/bin/sync-charag ".local_fullpath." ".remote_fullpath)' | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment