Last active
December 18, 2015 00:39
-
-
Save 3cooper/5698023 to your computer and use it in GitHub Desktop.
Powerline rsync segment
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
let g:powerline_rsync = '0' | |
fu! SetRsync(text) | |
let g:powerline_rsync=a:text | |
execute ":redrawstatus!" | |
endf | |
fu! OnWrite() | |
... | |
... | |
execute ':silent Start! ~/Yakabod/Workspaces/sync.sh ' . expand('%') . ' ' . a:user . '@' . a:server . ':' . a:destination | |
endf |
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
vim --servername main --remote-expr "SetRsync('1')" | |
ERR=$((/usr/bin/rsync --quiet $1 $2) 2>&1) | |
if [ $? -eq "0" ]; then | |
vim --servername main --remote-expr "SetRsync('0')" | |
else | |
vim --servername main --remote-expr "SetRsync('$ERR')" | |
fi |
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
@requires_segment_info | |
def rsync_indicator(pl, segment_info, text='RSYNC'): | |
'''Return a rsync mode indicator. | |
:param string text: | |
text to display if rsync mode is enabled | |
''' | |
result = vim.eval('g:powerline_rsync') | |
if result.isdigit(): | |
if int(result): | |
text='RSYNC' | |
else: | |
text=None | |
else: | |
text='RSYNC !' | |
return text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment