From 3285903aae57c98ab06ee2182a12e559f03982bb Mon Sep 17 00:00:00 2001 From: lestrrat <49281+lestrrat@users.noreply.github.com> Date: Thu, 4 Feb 2021 09:34:44 +0900 Subject: [PATCH] Enable/Disable pager from config (#242) --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 2b8fc3f8..44fd3332 100644 --- a/main.go +++ b/main.go @@ -140,6 +140,7 @@ func validateOptions(cmd *cobra.Command) error { width = viper.GetUint("width") localOnly = viper.GetBool("local") mouse = viper.GetBool("mouse") + pager = viper.GetBool("pager") // validate the glamour style style = viper.GetString("style") @@ -270,13 +271,13 @@ func executeArg(cmd *cobra.Command, arg string, w io.Writer) error { } // display - if cmd.Flags().Changed("pager") { - pager := os.Getenv("PAGER") - if pager == "" { - pager = "less -r" + if pager || cmd.Flags().Changed("pager") { + pagerCmd := os.Getenv("PAGER") + if pagerCmd == "" { + pagerCmd = "less -r" } - pa := strings.Split(pager, " ") + pa := strings.Split(pagerCmd, " ") c := exec.Command(pa[0], pa[1:]...) c.Stdin = strings.NewReader(content) c.Stdout = os.Stdout