mirror of
https://github.com/jimeh/tmux-themepack.git
synced 2026-02-19 11:16:43 +00:00
feat: Make all themes easily user-customizable
This is achieved by using custom @-prefixed tmux options which are set with the `-o` option, meaning, the theme will only set the value if it is not already set. This allows users to override any of the options in the theme by simply setting them before loading the theme. Additionally all themes are now generated using a custom theme builder, that allows sharing various parts of themes between them easily.
This commit is contained in:
@@ -35,10 +35,10 @@ func TestDefaultTheme(t *testing.T) {
|
||||
"message-style": "fg=black,bg=yellow",
|
||||
"status-interval": "15",
|
||||
"status-justify": "left",
|
||||
"status-left": "[#S]",
|
||||
"status-left-length": "10",
|
||||
"status-left": "[#S] ",
|
||||
"status-left-length": "40",
|
||||
"status-left-style": "fg=black,bg=green",
|
||||
"status-right": "\"#H\" %H:%M %d-%b-%y",
|
||||
"status-right": " \"#H\" %H:%M %d-%b-%y",
|
||||
"status-right-length": "40",
|
||||
"status-right-style": "fg=black,bg=green",
|
||||
"status-style": "fg=black,bg=green",
|
||||
|
||||
@@ -63,8 +63,9 @@ func TestPowerlineBlockThemes(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
tmuxSetup()
|
||||
|
||||
_, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err, `%s: Failed to load theme`, tt.filename)
|
||||
out, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err,
|
||||
`%s: Failed to load theme: %s`, tt.filename, out)
|
||||
|
||||
tmuxHasOptions(t, tt.filename, tmux.GlobalWindow, tmux.Options{
|
||||
"clock-mode-colour": tt.color1,
|
||||
|
||||
@@ -63,8 +63,9 @@ func TestPowerlineDefaultThemes(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
tmuxSetup()
|
||||
|
||||
_, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err, `%s: Failed to load theme`, tt.filename)
|
||||
out, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err,
|
||||
`%s: Failed to load theme: %s`, tt.filename, out)
|
||||
|
||||
tmuxHasOptions(t, tt.filename, tmux.GlobalWindow, tmux.Options{
|
||||
"clock-mode-colour": tt.color1,
|
||||
@@ -74,7 +75,7 @@ func TestPowerlineDefaultThemes(t *testing.T) {
|
||||
"pane-border-style": "fg=colour238",
|
||||
"window-status-activity-style": "fg=colour245,bg=colour233",
|
||||
"window-status-current-format": "#[fg=colour233,bg=black]\ue0b0#[fg=" + tt.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]\ue0b2",
|
||||
"window-status-current-style": "fg=colour235,bg=colour100",
|
||||
"window-status-current-style": "fg=" + tt.color2 + ",bg=black",
|
||||
"window-status-format": " #I:#W#F ",
|
||||
"window-status-separator": "",
|
||||
})
|
||||
|
||||
@@ -58,8 +58,9 @@ func TestPowerlineDoubleThemes(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
tmuxSetup()
|
||||
|
||||
_, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err, `%s: Failed to load theme`, tt.filename)
|
||||
out, err := tm.Exec("source-file", tt.filename)
|
||||
assert.NoErrorf(t, err,
|
||||
`%s: Failed to load theme: %s`, tt.filename, out)
|
||||
|
||||
tmuxHasOptions(t, tt.filename, tmux.GlobalWindow, tmux.Options{
|
||||
"clock-mode-colour": tt.color1,
|
||||
@@ -69,7 +70,7 @@ func TestPowerlineDoubleThemes(t *testing.T) {
|
||||
"pane-border-style": "fg=colour238",
|
||||
"window-status-activity-style": "fg=colour245,bg=colour233",
|
||||
"window-status-current-format": "#[fg=colour233,bg=black]\ue0b0#[fg=" + tt.color2 + ",nobold] #I:#W#F #[fg=colour233,bg=black,nobold]\ue0b2",
|
||||
"window-status-current-style": "fg=colour235,bg=colour100",
|
||||
"window-status-current-style": "fg=" + tt.color2 + ",bg=black",
|
||||
"window-status-format": " #I:#W#F ",
|
||||
"window-status-separator": "",
|
||||
})
|
||||
|
||||
@@ -51,11 +51,11 @@ func tmuxHasOptions(t *testing.T, theme string, s tmux.Scope, m tmux.Options) {
|
||||
if err == nil {
|
||||
for k, v := range m {
|
||||
_, ok := opts[k]
|
||||
assert.Truef(t, ok, `%s: Key "%s" is not available`, theme, k)
|
||||
assert.Truef(t, ok, `Key "%s" is not available in %s`, k, theme)
|
||||
if ok {
|
||||
assert.Equalf(t,
|
||||
v, opts[k],
|
||||
`%s: Key "%s" is not "%s"`, theme, k, v,
|
||||
`Key "%s" in "%s"`, k, theme,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user