diff --git a/docs/docs/segment-git.md b/docs/docs/segment-git.md index ad29a885..9e1906f6 100644 --- a/docs/docs/segment-git.md +++ b/docs/docs/segment-git.md @@ -12,6 +12,7 @@ Local changes can also shown by default using the following syntax for both the - `+` added - `~` modified - `-` deleted +- `?` untracked ## Sample Configuration @@ -56,6 +57,7 @@ Local changes can also shown by default using the following syntax for both the - rebase_icon: `string` - icon/text to display before the context when in a rebase - defaults to `\uE728 ` - cherry_pick_icon: `string` - icon/text to display before the context when doing a cherry-pick - defaults to `\uE29B ` - merge_icon: `string` icon/text to display before the merge context - defaults to `\uE727 ` +- no_commits_icon: `string` icon/text to display when there are no commits in the repo - defaults to `\uF594 ` ### Upstream context diff --git a/src/segment_git.go b/src/segment_git.go index 96fc6a11..1fc007fa 100644 --- a/src/segment_git.go +++ b/src/segment_git.go @@ -78,6 +78,8 @@ const ( CherryPickIcon Property = "cherry_pick_icon" // CommitIcon shows before the detached context CommitIcon Property = "commit_icon" + // NoCommitsIcon shows when there are no commits in the repo yet + NoCommitsIcon Property = "no_commits_icon" // TagIcon shows before the tag context TagIcon Property = "tag_icon" // DisplayStashCount show stash count or not @@ -309,6 +311,9 @@ func (g *git) getPrettyHEADName() string { } // fallback to commit ref = g.getGitCommandOutput("rev-parse", "--short", "HEAD") + if ref == "" { + return g.props.getString(NoCommitsIcon, "\uF594 ") + } return fmt.Sprintf("%s%s", g.props.getString(CommitIcon, "\uF417"), ref) }