Update for use custom indicators on root segment

This commit is contained in:
Amaury 2018-05-28 22:37:56 -03:00
parent c5272ced26
commit 50f1c01aa6

View file

@ -4,11 +4,22 @@ from ..utils import BasicSegment
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline
config = self.powerline.config
def exists(obj, chain):
_key = chain.pop(0)
if _key in obj:
return exists(obj[_key], chain) if chain else obj[_key]
def indicators(default, shell, path='root.indicators'):
indicator = exists(config, (path + '.' + shell).split('.'))
return indicator if indicator else default
root_indicators = {
'bash': ' \\$ ',
'tcsh': ' %# ',
'zsh': ' %# ',
'bare': ' $ ',
'bash': indicators(' \\$ ', 'bash'),
'tcsh': indicators(' %# ', 'tcsh'),
'zsh': indicators(' %# ', 'zsh'),
'bare': indicators(' $ ', 'bare'),
}
bg = powerline.theme.CMD_PASSED_BG
fg = powerline.theme.CMD_PASSED_FG