diff --git a/config_cmd.go b/config_cmd.go index a90b9031..99d2a3a8 100644 --- a/config_cmd.go +++ b/config_cmd.go @@ -21,7 +21,9 @@ mouse: false # use pager to display markdown pager: false # word-wrap at width -width: 80` +width: 80 +# homepage title +title: Glow` var configCmd = &cobra.Command{ Use: "config", diff --git a/main.go b/main.go index 47424e4f..499b34ce 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ var ( showAllFiles bool localOnly bool mouse bool + title string rootCmd = &cobra.Command{ Use: "glow [SOURCE|DIR]", @@ -141,6 +142,7 @@ func validateOptions(cmd *cobra.Command) error { localOnly = viper.GetBool("local") mouse = viper.GetBool("mouse") pager = viper.GetBool("pager") + title = viper.GetString("title") // validate the glamour style style = viper.GetString("style") @@ -334,6 +336,7 @@ func runTUI(workingDirectory string, stashedOnly bool) error { cfg.ShowAllFiles = showAllFiles cfg.GlamourMaxWidth = width cfg.GlamourStyle = style + cfg.Title = title if stashedOnly { cfg.DocumentTypes.Add(ui.StashedDoc, ui.NewsDoc) @@ -353,8 +356,6 @@ func runTUI(workingDirectory string, stashedOnly bool) error { return err } - // Exit message - fmt.Printf("\n Thanks for using Glow!\n\n") return nil } @@ -385,6 +386,7 @@ func init() { rootCmd.Flags().BoolVarP(&showAllFiles, "all", "a", false, "show system files and directories (TUI-mode only)") rootCmd.Flags().BoolVarP(&localOnly, "local", "l", false, "show local files only; no network (TUI-mode only)") rootCmd.Flags().BoolVarP(&mouse, "mouse", "m", false, "enable mouse wheel (TUI-mode only)") + rootCmd.Flags().StringVarP(&title, "title", "t", "Glow", "homepage title") rootCmd.Flags().MarkHidden("mouse") // Config bindings @@ -395,6 +397,7 @@ func init() { viper.SetDefault("style", "auto") viper.SetDefault("width", 0) viper.SetDefault("local", "false") + viper.SetDefault("title", "Glow") // Stash stashCmd.PersistentFlags().StringVarP(&memo, "memo", "m", "", "memo/note for stashing") diff --git a/ui/config.go b/ui/config.go index 67d94d69..1c635797 100644 --- a/ui/config.go +++ b/ui/config.go @@ -7,6 +7,7 @@ type Config struct { HomeDir string `env:"HOME"` GlamourMaxWidth uint GlamourStyle string + Title string // Which directory should we start from? WorkingDirectory string diff --git a/ui/pager.go b/ui/pager.go index 7f43019c..1ffe864b 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -363,7 +363,7 @@ func (m pagerModel) statusBarView(b *strings.Builder) { ) // Logo - logo := glowLogoView(" Glow ") + logo := glowLogoView(fmt.Sprintf(" %s ", m.common.cfg.Title)) // Scroll percent percent := math.Max(minPercent, math.Min(maxPercent, m.viewport.ScrollPercent())) diff --git a/ui/stash.go b/ui/stash.go index 6e85d585..0c0be51d 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -1157,7 +1157,7 @@ func (m stashModel) view() string { } else if m.filterState == filtering { logoOrFilter += m.filterInput.View() } else { - logoOrFilter += glowLogoView(" Glow ") + logoOrFilter += glowLogoView(fmt.Sprintf(" %s ", m.common.cfg.Title)) if m.showStatusMessage { logoOrFilter += " " + m.statusMessage.String() }