diff --git a/README.md b/README.md index e6295711..fd4ca815 100644 --- a/README.md +++ b/README.md @@ -309,6 +309,11 @@ The `vcs` segment provides one option: - `show_symbol`: If `true`, the version control system segment will start with a symbol representing the specific version control system in use in the current directory. + +The options for the `git` segment are: + +- `master_is_M`: If `true`, the master branch will be abbreviated to M. +- `branch_max_length`: Maximum number of characters displayed for the branch name. The options for the `battery` segment are: diff --git a/powerline_shell/segments/git.py b/powerline_shell/segments/git.py index de2b049e..435e0b01 100644 --- a/powerline_shell/segments/git.py +++ b/powerline_shell/segments/git.py @@ -66,7 +66,19 @@ def build_stats(): class Segment(ThreadedSegment): def run(self): self.stats, self.branch = build_stats() + + if self.branch: + # 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[:branch_max_length] + u'\u2026' + + def add_to_powerline(self): self.join() if not self.stats: