Skip to content

Conversation

@Divy13ansh
Copy link
Contributor

@Divy13ansh Divy13ansh commented Oct 5, 2025

Closes: #21

This PR adds full support for custom themes in GITx, allowing users to define their own color schemes in TOML files. Users can now:

  • Load custom themes from ~/.config/gitx/themes/.
  • Have full control over foreground, background, normal, bright, and dark colors.

Usage:

  • Place your custom theme in ~/.config/gitx/themes/.
  • Update theme in ~/.config/gitx/config.toml.
  • Loaded theme will be set as default.
  • Switch between themes using <ctrl + t>
  • Defaults to a built-in theme if config.toml or theme file is missing.

config.toml

Screenshot 2025-10-06 000312

theme_1.toml

Screenshot 2025-10-06 000303

run gitx

Screenshot 2025-10-06 000147

<ctrl + t>

Screenshot 2025-10-06 000208

@bakayu bakayu self-requested a review October 5, 2025 20:14
Comment on lines 245 to 289
func load_config() (*themeConfig, error){
cfgPath := filepath.Join(os.Getenv("HOME"), ".config", "gitx", "config.toml")
if _,err := os.Stat(cfgPath); os.IsNotExist(err) {
return &themeConfig{Theme: DefaultThemeName}, nil //fallback
}

var cfg themeConfig
if _, err := toml.DecodeFile(cfgPath, &cfg); err != nil {
return nil, err
}

return &cfg, nil
}

func load_custom_theme(name string) (*Palette, error){
themePath := filepath.Join(os.Getenv("HOME"), ".config", "gitx", "themes", name+".toml")
if _,err := os.Stat(themePath); os.IsNotExist(err) {
return nil, fmt.Errorf("theme not found: %s", name)
}

var tf ThemeFile
if _, err := toml.DecodeFile(themePath, &tf); err != nil {
return nil, err
}

// Create a Palette from the ThemeFile
p := Palette{
Fg: tf.Fg,
Bg: tf.Bg,
Black: tf.Normal["Black"], Red: tf.Normal["Red"], Green: tf.Normal["Green"], Yellow: tf.Normal["Yellow"],
Blue: tf.Normal["Blue"], Magenta: tf.Normal["Magenta"], Cyan: tf.Normal["Cyan"], White: tf.Normal["White"],

BrightBlack: tf.Bright["Black"], BrightRed: tf.Bright["Red"], BrightGreen: tf.Bright["Green"], BrightYellow: tf.Bright["Yellow"],
BrightBlue: tf.Bright["Blue"], BrightMagenta: tf.Bright["Magenta"], BrightCyan: tf.Bright["Cyan"], BrightWhite: tf.Bright["White"],

DarkBlack: tf.Dark["Black"], DarkRed: tf.Dark["Red"], DarkGreen: tf.Dark["Green"], DarkYellow: tf.Dark["Yellow"],
DarkBlue: tf.Dark["Blue"], DarkMagenta: tf.Dark["Magenta"], DarkCyan: tf.Dark["Cyan"], DarkWhite: tf.Dark["White"],

}

Palettes[name] = p // Add to Palettes map for future use
Themes[name] = NewThemeFromPalette(p) // Add to Themes map

return &p, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the scope of this PR does not include adding proper functionality for the user provided config file, that is .config/gitx/config.toml. Would you be interested in refactoring this into a separate file? I'll help in the effort by pushing some changes in your branch if you are okay with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, can you please clarify what you mean by "proper functionality" for the config file.
And yeah, I’m cool with refactoring and happy to have your help on my branch.

Copy link
Member

@bakayu bakayu Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not clarifying it properly.
By "proper functionality" I mean basic settings any cli or tui app may have that can be configured via the config file.
For example the Theme setting you have implemented that can be found in the users's .config folder, in the config.toml file.
To have a proper chat about this you can join the discord server linked in the readme file and ping mere there in the appropriate channel, my discord handle is @bakayu.
This is a big effort feature request and I appreciate your help in this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah got it, thanks for clarifying, I'll ping you on discord so we can discuss and refactor together.

@bakayu
Copy link
Member

bakayu commented Oct 5, 2025

Can you resolve the merge conflict so that the CI can be run?

@Divy13ansh
Copy link
Contributor Author

Can you resolve the merge conflict so that the CI can be run?

Sure, I’ll resolve it.

@Divy13ansh Divy13ansh requested a review from bakayu October 9, 2025 08:55
@bakayu bakayu merged commit 6c04133 into gitxtui:master Oct 9, 2025
2 checks passed
@bakayu bakayu added the hacktoberfest-accepted This PR is accepted under the hacktoberfest challenge label Oct 9, 2025
@bakayu
Copy link
Member

bakayu commented Oct 9, 2025

Thank you for the contribution! @Divy13ansh
This will be a great addition to the TUI. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted This PR is accepted under the hacktoberfest challenge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] - Custom Theme Support

2 participants