Allow side, extension and renderer module to be specified in powerline-prompt

Refs #84.
This commit is contained in:
Kim Silkebækken 2013-01-21 10:50:07 +01:00
parent 2eb07e894e
commit fcb07943eb
1 changed files with 16 additions and 4 deletions

View File

@ -1,13 +1,25 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
'''Powerline terminal prompt.'''
'''Powerline prompt script.'''
import argparse
try:
from powerline.core import Powerline
except ImportError:
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from powerline.core import Powerline
from powerline.core import Powerline # NOQA
pl = Powerline('terminal')
print(pl.renderer.render(None).encode('utf-8'))
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('side', nargs='?', default='all', choices=('all', 'left', 'right'))
parser.add_argument('--renderer_module', default='shell', choices=('shell', 'zsh_prompt'))
parser.add_argument('--ext', default='shell')
if __name__ == '__main__':
args = parser.parse_args()
pl = Powerline(ext=args.ext, renderer_module=args.renderer_module)
segments = pl.renderer.get_theme().get_segments()
if args.side != 'all':
segments = [s for s in segments if s['side'] == args.side]
print(pl.renderer.render(None, segments=segments).encode('utf-8'))