This commit is contained in:
Amaury Catelan 2018-06-06 16:53:41 +00:00 committed by GitHub
commit 1a2232a327
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -289,6 +289,19 @@ The options for the `battery` segment are:
- `always_show_percentage`: If true, show percentage when fully charged on AC.
- `low_threshold`: Threshold percentage for low-battery indicator color.
The `root` segment provides the option to customize `indicators` on each of the supported shells. For example:
```
{
"root": {
"indicators": {
"bash": " bash 🤖 ",
"zsh": " zsh 🤖 "
}
}
}
```
### Contributing new types of segments
The `powerline_shell/segments` directory contains python scripts which are

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