Skip to content

Commit b821624

Browse files
authored
Set 'Clear' to #[none] (#108)
* Cosmetics * Default 'Clear' style is now #[none] None actually resets all attributes. * Always append the Clear attribute to gitmux status string Fix #107
1 parent 076c75f commit b821624

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

.gitmux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tmux:
3232
# https://man7.org/linux/man-pages/man1/tmux.1.html#STYLES.
3333
styles:
3434
# Clear previous style.
35-
clear: "#[fg=default]"
35+
clear: "#[none]"
3636
# Special tree state strings such as [rebase], [merge], etc.
3737
state: "#[fg=red,bold]"
3838
# Local branch name

config.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
_ "embed"
55
"fmt"
66

7-
"github.com/arl/gitmux/tmux"
87
"gopkg.in/yaml.v3"
8+
9+
"github.com/arl/gitmux/tmux"
910
)
1011

1112
// Config configures output formatting.

testdata/default.output.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ with some different content
5151

5252
-- empty_file --
5353
-- output.golden --
54-
#[fg=default]#[fg=default]#[fg=white,bold]⎇ #[fg=default]#[fg=white,bold]main#[fg=default] - #[fg=default]#[fg=green,bold]● 1 #[fg=red,bold]✚ 1 #[fg=cyan,bold]⚑ 1 #[fg=magenta,bold]… 2#[fg=default,bg=default]
54+
#[none]#[none]#[fg=white,bold]⎇ #[none]#[fg=white,bold]main#[none] - #[none]#[fg=green,bold]● 1 #[fg=red,bold]✚ 1 #[fg=cyan,bold]⚑ 1 #[fg=magenta,bold]… 2#[fg=default,bg=default]#[none]

tmux/formater.go

+14-12
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ func (d *direction) UnmarshalYAML(value *yaml.Node) error {
8585
}
8686

8787
type options struct {
88-
BranchMaxLen int `yaml:"branch_max_len"`
89-
BranchTrim direction `yaml:"branch_trim"`
90-
Ellipsis string `yaml:"ellipsis"`
91-
HideClean bool `yaml:"hide_clean"`
92-
SwapDivergence bool `yaml:"swap_divergence"`
88+
BranchMaxLen int `yaml:"branch_max_len"`
89+
BranchTrim direction `yaml:"branch_trim"`
90+
Ellipsis string `yaml:"ellipsis"`
91+
HideClean bool `yaml:"hide_clean"`
92+
SwapDivergence bool `yaml:"swap_divergence"`
9393
}
9494

9595
// A Formater formats git status to a tmux style string.
@@ -135,6 +135,8 @@ func truncate(s, ellipsis string, max int, dir direction) string {
135135

136136
// Format writes st as json into w.
137137
func (f *Formater) Format(w io.Writer, st *gitstatus.Status) error {
138+
defer fmt.Fprintf(w, "%s", f.Styles.Clear)
139+
138140
f.st = st
139141

140142
// Overall working tree state
@@ -241,23 +243,23 @@ func (f *Formater) divergence() string {
241243
return ""
242244
}
243245

244-
behind := ""
245-
ahead := ""
246+
behind := ""
247+
ahead := ""
246248
s := f.Styles.Clear + f.Styles.Divergence
247249
if f.st.BehindCount != 0 {
248-
behind = fmt.Sprintf("%s%d", f.Symbols.Behind, f.st.BehindCount)
250+
behind = fmt.Sprintf("%s%d", f.Symbols.Behind, f.st.BehindCount)
249251
}
250252

251253
if f.st.AheadCount != 0 {
252254
ahead = fmt.Sprintf("%s%d", f.Symbols.Ahead, f.st.AheadCount)
253255
}
254256

255257
if !f.Options.SwapDivergence {
256-
// Behind first, ahead second
257-
s += behind + ahead
258+
// Behind first, ahead second
259+
s += behind + ahead
258260
} else {
259-
// Ahead first, behind second
260-
s += ahead + behind
261+
// Ahead first, behind second
262+
s += ahead + behind
261263
}
262264

263265
return s

0 commit comments

Comments
 (0)