Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove goodbye message & make title configurable #331

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
showAllFiles bool
localOnly bool
mouse bool
title string

rootCmd = &cobra.Command{
Use: "glow [SOURCE|DIR]",
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions ui/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ui/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion ui/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down