mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Merge f3f13e9984 into 4b19aa47f1
This commit is contained in:
commit
9f0506ae72
|
|
@ -319,6 +319,10 @@ The options for the `time` segment are:
|
|||
|
||||
- `format`: Format string as used by strftime function, e.g. `%H:%M`.
|
||||
|
||||
The options for the `root` segment are:
|
||||
|
||||
- `indicator`: Set custom indicator, e.g. ` → `.
|
||||
|
||||
### Contributing new types of segments
|
||||
|
||||
The `powerline_shell/segments` directory contains python scripts which are
|
||||
|
|
|
|||
|
|
@ -4,15 +4,20 @@ from ..utils import BasicSegment
|
|||
class Segment(BasicSegment):
|
||||
def add_to_powerline(self):
|
||||
powerline = self.powerline
|
||||
indicator = self._get_indicator(powerline.args.shell, powerline)
|
||||
bg = powerline.theme.CMD_PASSED_BG
|
||||
fg = powerline.theme.CMD_PASSED_FG
|
||||
if powerline.args.prev_error != 0:
|
||||
fg = powerline.theme.CMD_FAILED_FG
|
||||
bg = powerline.theme.CMD_FAILED_BG
|
||||
powerline.append(indicator, fg, bg, sanitize=False)
|
||||
|
||||
def _get_indicator(self, shell, powerline):
|
||||
custom_indicator = powerline.segment_conf("root", "indicator", None)
|
||||
root_indicators = {
|
||||
'bash': ' \\$ ',
|
||||
'tcsh': ' %# ',
|
||||
'zsh': ' %# ',
|
||||
'bare': ' $ ',
|
||||
}
|
||||
bg = powerline.theme.CMD_PASSED_BG
|
||||
fg = powerline.theme.CMD_PASSED_FG
|
||||
if powerline.args.prev_error != 0:
|
||||
fg = powerline.theme.CMD_FAILED_FG
|
||||
bg = powerline.theme.CMD_FAILED_BG
|
||||
powerline.append(root_indicators[powerline.args.shell], fg, bg, sanitize=False)
|
||||
return custom_indicator or root_indicators[shell]
|
||||
|
|
|
|||
Loading…
Reference in a new issue