mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Updated git.py - branch name truncation options
Two config.json options added that help truncate git branch names. The first shortens "master" to "M". The second truncates the branch name to a given length. For example, with these config settings:
```
"git": {
"master_is_M": true,
"branch_max_length": 5
}
```
We would see "M" in lieu of "master" and "whate…" in lieu of "whatever".
This commit is contained in:
parent
a9b8c9bb39
commit
ebeb4737fd
|
|
@ -66,7 +66,17 @@ def build_stats():
|
|||
class Segment(ThreadedSegment):
|
||||
def run(self):
|
||||
self.stats, self.branch = build_stats()
|
||||
|
||||
# Abbreviates master branch to M
|
||||
if self.powerline.segment_conf("git", "master_is_M"):
|
||||
if self.branch == "master":
|
||||
self.branch = "M"
|
||||
|
||||
# Truncates branch length
|
||||
branch_max_length = self.powerline.segment_conf("git", "branch_max_length", -1)
|
||||
if len(self.branch) > branch_max_length :
|
||||
self.branch = self.branch = self.branch[:branch_max_length] + u'\u2026'
|
||||
|
||||
def add_to_powerline(self):
|
||||
self.join()
|
||||
if not self.stats:
|
||||
|
|
|
|||
Loading…
Reference in a new issue