feat(config): add theme customization (#81)

Added theme customization via config.toml
#17
```
[theme]
border = "#665C54"
accent = "#FABD2F"
muted = "#928374"
text = "#EBDBB2"
text_sel = "#FBF1C7"
match = "#FE8019"
desc = "#A89984"
desc_sel = "#EBDBB2"
sel_bg = "#504945"
scroll_info = "#83A598"
ghost_text = "#7C6F64"
hist= "#fe8019"
hist_sel = "#d65d0e"
sys = "#fb4934"
sys_sel = "#cc241d"
alias = "#b8bb26"
alias_sel = "#98971a"


```

---------

Co-authored-by: verse91 <versedev.store@proton.me>
Co-authored-by: VERSE <sunnyone0901@gmail.com>
This commit is contained in:
Bruce12
2026-08-04 13:49:10 +07:00
committed by GitHub
co-authored by verse91 VERSE
parent b79d25a082
commit b14b26e663
10 changed files with 494 additions and 179 deletions
+106
View File
@@ -0,0 +1,106 @@
package root
import (
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
"github.com/versenilvis/iris/internal/config"
)
var ThemeCmd = &cobra.Command{
Use: "theme",
Short: "manage iris theme",
}
var ThemeInitCmd = &cobra.Command{
Use: "init",
Short: "initialize default theme file with comments",
Run: func(cmd *cobra.Command, args []string) {
path, err := config.ThemePath()
if err != nil {
fmt.Printf("failed to get theme path: %v\n", err)
return
}
if _, statErr := os.Stat(path); statErr == nil {
fmt.Printf("theme file already exists at %s\n", path)
return
}
_ = os.MkdirAll(filepath.Dir(path), 0755)
defaultContent := `# ~/.config/iris/theme.toml
# iris theme file
# overlay border color
border = "#a277ff"
# accent color for selected marker and icon
accent = "#61ffca"
# muted color for unselected icons
muted = "#6d6a7f"
# default text color
text = "#edecee"
# text color when selected
text_sel = "#ffffff"
# footer shortcut key color
key = "#a277ff"
# matched text color
match = "#61ffca"
# description text color
desc = "#9692a8"
# description text color when selected
desc_sel = "#edecee"
# selected row background
sel_bg = "#3d375e"
# selected tag pill text color
sel_text = "#110f18"
# scroll counter color
scroll_info = "#a277ff"
# inline ghost text color
ghost_text = "#4B4A4C"
# "system" tag background color
sys = "#1e1d28"
# "system" tag selected background color
sys_sel = "#a277ff"
# "history" tag background color
hist = "#1a2d36"
# "history" tag selected background color
hist_sel = "#61ffca"
# "alias" tag background color
alias = "#2a2342"
# "alias" tag selected background color (and alias word color)
alias_sel = "#a277ff"
`
err = os.WriteFile(path, []byte(defaultContent), 0644)
if err != nil {
fmt.Printf("failed to write theme file: %v\n", err)
return
}
fmt.Printf("initialized theme file at %s\n", path)
},
}
func init() {
ThemeCmd.AddCommand(ThemeInitCmd)
rootCmd.AddCommand(ThemeCmd)
}