mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
parent
03dbee0386
commit
4e27952b3f
|
@ -63,3 +63,10 @@ Local changes can also shown by default using the following syntax for both the
|
||||||
- gitlab_icon: `string` - icon/text to display when the upstream is Gitlab - defaults to `\uF296 `
|
- gitlab_icon: `string` - icon/text to display when the upstream is Gitlab - defaults to `\uF296 `
|
||||||
- bitbucket_icon: `string` - icon/text to display when the upstream is Bitbucket - defaults to `\uF171 `
|
- bitbucket_icon: `string` - icon/text to display when the upstream is Bitbucket - defaults to `\uF171 `
|
||||||
- git_icon: `string` - icon/text to display when the upstream is not known/mapped - defaults to `\uE5FB `
|
- git_icon: `string` - icon/text to display when the upstream is not known/mapped - defaults to `\uE5FB `
|
||||||
|
|
||||||
|
### Colors
|
||||||
|
|
||||||
|
- working_color: `string` [hex color code][colors] - foreground color for the working area status - defaults to segment foreground
|
||||||
|
- staging_color: `string` [hex color code][colors] - foreground color for the staging area status - defaults to segment foreground
|
||||||
|
|
||||||
|
[colors]: https://htmlcolorcodes.com/color-chart/material-design-color-chart/
|
||||||
|
|
|
@ -27,7 +27,7 @@ type gitStatus struct {
|
||||||
untracked int
|
untracked int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *gitStatus) string(prefix string) string {
|
func (s *gitStatus) string(prefix string, color string) string {
|
||||||
var status string
|
var status string
|
||||||
stringIfValue := func(value int, prefix string) string {
|
stringIfValue := func(value int, prefix string) string {
|
||||||
if value > 0 {
|
if value > 0 {
|
||||||
|
@ -41,7 +41,7 @@ func (s *gitStatus) string(prefix string) string {
|
||||||
status += stringIfValue(s.untracked, "?")
|
status += stringIfValue(s.untracked, "?")
|
||||||
status += stringIfValue(s.unmerged, "x")
|
status += stringIfValue(s.unmerged, "x")
|
||||||
if status != "" {
|
if status != "" {
|
||||||
return fmt.Sprintf(" %s%s", prefix, status)
|
return fmt.Sprintf(" <%s>%s%s</>", color, prefix, status)
|
||||||
}
|
}
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,10 @@ const (
|
||||||
GitlabIcon Property = "gitlab_icon"
|
GitlabIcon Property = "gitlab_icon"
|
||||||
//GitIcon shows when the upstream can't be identified
|
//GitIcon shows when the upstream can't be identified
|
||||||
GitIcon Property = "git_icon"
|
GitIcon Property = "git_icon"
|
||||||
|
//WorkingColor if set, the color to use on the working area
|
||||||
|
WorkingColor Property = "working_color"
|
||||||
|
//StagingColor if set, the color to use on the staging area
|
||||||
|
StagingColor Property = "staging_color"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *git) enabled() bool {
|
func (g *git) enabled() bool {
|
||||||
|
@ -130,8 +134,8 @@ func (g *git) string() string {
|
||||||
} else if g.repo.upstream == "" {
|
} else if g.repo.upstream == "" {
|
||||||
fmt.Fprintf(buffer, " %s", g.props.getString(BranchGoneIcon, "\u2262"))
|
fmt.Fprintf(buffer, " %s", g.props.getString(BranchGoneIcon, "\u2262"))
|
||||||
}
|
}
|
||||||
staging := g.repo.staging.string(g.props.getString(LocalStagingIcon, "\uF046"))
|
staging := g.repo.staging.string(g.props.getString(LocalStagingIcon, "\uF046"), g.props.getColor(StagingColor, g.props.foreground))
|
||||||
working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "\uF044"))
|
working := g.repo.working.string(g.props.getString(LocalWorkingIcon, "\uF044"), g.props.getColor(WorkingColor, g.props.foreground))
|
||||||
fmt.Fprint(buffer, staging)
|
fmt.Fprint(buffer, staging)
|
||||||
if staging != "" && working != "" {
|
if staging != "" && working != "" {
|
||||||
fmt.Fprint(buffer, g.props.getString(StatusSeparatorIcon, " |"))
|
fmt.Fprint(buffer, g.props.getString(StatusSeparatorIcon, " |"))
|
||||||
|
|
|
@ -268,26 +268,26 @@ func TestParseGitBranchInfoNoRemote(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitStatusUnmerged(t *testing.T) {
|
func TestGitStatusUnmerged(t *testing.T) {
|
||||||
expected := " working: x1"
|
expected := " <#123456>working: x1</>"
|
||||||
status := &gitStatus{
|
status := &gitStatus{
|
||||||
unmerged: 1,
|
unmerged: 1,
|
||||||
}
|
}
|
||||||
assert.Equal(t, expected, status.string("working:"))
|
assert.Equal(t, expected, status.string("working:", "#123456"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitStatusUnmergedModified(t *testing.T) {
|
func TestGitStatusUnmergedModified(t *testing.T) {
|
||||||
expected := " working: ~3 x1"
|
expected := " <#123456>working: ~3 x1</>"
|
||||||
status := &gitStatus{
|
status := &gitStatus{
|
||||||
unmerged: 1,
|
unmerged: 1,
|
||||||
modified: 3,
|
modified: 3,
|
||||||
}
|
}
|
||||||
assert.Equal(t, expected, status.string("working:"))
|
assert.Equal(t, expected, status.string("working:", "#123456"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitStatusEmpty(t *testing.T) {
|
func TestGitStatusEmpty(t *testing.T) {
|
||||||
expected := ""
|
expected := ""
|
||||||
status := &gitStatus{}
|
status := &gitStatus{}
|
||||||
assert.Equal(t, expected, status.string("working:"))
|
assert.Equal(t, expected, status.string("working:", "#123456"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseGitStatsWorking(t *testing.T) {
|
func TestParseGitStatsWorking(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue