Skip to content
Browse files

Add modified_buffers segment

This segment returns a comma-separated list of modified buffers. The
segment is not enabled by default.

Closes #173.
  • Loading branch information...
1 parent 5399265 commit d386ae71fdb3c7e5d18353af33b59360f583dc5c @Lokaltog committed Feb 8, 2013
Showing with 11 additions and 1 deletion.
  1. +2 −1 powerline/config_files/colorschemes/vim/default.json
  2. +9 −0 powerline/segments/vim.py
View
3 powerline/config_files/colorschemes/vim/default.json
@@ -82,7 +82,8 @@
"line_percent_gradient6": { "fg": "gradient6", "bg": "gray4" },
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
- "col_current": { "fg": "gray6", "bg": "gray10" }
+ "col_current": { "fg": "gray6", "bg": "gray10" },
+ "modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
},
"mode_translations": {
"nc": {
View
9 powerline/segments/vim.py
@@ -167,6 +167,15 @@ def col_current(virtcol=True):
return vim_funcs['virtcol' if virtcol else 'col']('.')
+def modified_buffers(text=u'+'):
+ '''Return a comma-separated list of modified buffers.'''
+ buffer_len = int(vim.eval('bufnr("$")'))
+ buffer_mod = [str(bufnr) for bufnr in range(1, buffer_len + 1) if vim.eval('getbufvar({0}, "&mod")'.format(bufnr)) == '1']
+ if buffer_mod:
+ return u'{0} {1}'.format(text, ','.join(buffer_mod))
+ return None
+
+
@memoize(2)
def branch():
repo = guess(os.path.abspath(vim.current.buffer.name or os.getcwd()))

0 comments on commit d386ae7

Please sign in to comment.
Something went wrong with that request. Please try again.