@@ -1,6 +1,7 @@
@@ -10,6 +11,7 @@ import (
12 tea "github.com/charmbracelet/bubbletea/v2"
13 tea "github.com/charmbracelet/bubbletea/v2"
14+ "github.com/charmbracelet/colorprofile"
13 "github.com/charmbracelet/crush/internal/app"
15 "github.com/charmbracelet/crush/internal/app"
14 "github.com/charmbracelet/crush/internal/config"
16 "github.com/charmbracelet/crush/internal/config"
15 "github.com/charmbracelet/crush/internal/db"
17 "github.com/charmbracelet/crush/internal/db"
@@ -17,6 +19,8 @@ import (
17 "github.com/charmbracelet/crush/internal/tui"
19 "github.com/charmbracelet/crush/internal/tui"
18 "github.com/charmbracelet/crush/internal/version"
20 "github.com/charmbracelet/crush/internal/version"
19 "github.com/charmbracelet/fang"
21 "github.com/charmbracelet/fang"
22+ "github.com/charmbracelet/lipgloss/v2"
23+ "github.com/charmbracelet/x/exp/charmtone"
20 "github.com/charmbracelet/x/term"
24 "github.com/charmbracelet/x/term"
21 "github.com/spf13/cobra"
25 "github.com/spf13/cobra"
@@ -93,7 +97,39 @@ crush -y
100+var heartbit = lipgloss.NewStyle().Foreground(charmtone.Dolly).SetString(`
102+ ███████████ ███████████
103+████████████████████████████
104+████████████████████████████
105+██████████▀██████▀██████████
106+██████████ ██████ ██████████
107+▀▀██████▄████▄▄████▄██████▀▀
108+ ████████████████████████
109+ ████████████████████
114+// copied from cobra:
115+const defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}
96func Execute() {
118func Execute() {
119+ // NOTE: very hacky: we create a colorprofile writer with STDOUT, then make
120+ // it forward to a bytes.Buffer, write the colored heartbit to it, and then
121+ // finally prepend it in the version template.
122+ // Unfortunately cobra doesn't give us a way to set a function to handle
123+ // printing the version, and PreRunE runs after the version is already
124+ // handled, so that doesn't work either.
125+ // This is the only way I could find that works relatively well.
126+ if term.IsTerminal(os.Stdout.Fd()) {
128+ w := colorprofile.NewWriter(os.Stdout, os.Environ())
130+ _, _ = w.WriteString(heartbit.String())
131+ rootCmd.SetVersionTemplate(b.String() + "\n" + defaultVersionTemplate)
97 if err := fang.Execute(
133 if err := fang.Execute(
98 context.Background(),
134 context.Background(),