Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions powerline_shell/segments/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down