diff --git a/tools/cli/infrastructure.go b/tools/cli/infrastructure.go index 429733006..2b19d76ff 100644 --- a/tools/cli/infrastructure.go +++ b/tools/cli/infrastructure.go @@ -323,7 +323,7 @@ func show_usage(cmd *cobra.Command) error { } output_text := output.String() if stdout_is_terminal && cmd.Annotations["allow-pager"] != "no" { - pager := exec.Command("less", "-iRXF"); + pager := exec.Command(kitty.DefaultPager[0], kitty.DefaultPager[1:]...); pager.Stdin = strings.NewReader(output_text) pager.Stdout = os.Stdout pager.Stderr = os.Stderr diff --git a/version.go b/version.go index 2bb7e4ad7..06d6531b2 100644 --- a/version.go +++ b/version.go @@ -2,10 +2,13 @@ package kitty import ( _ "embed" + "encoding/json" "fmt" + "os" "regexp" "runtime/debug" "strconv" + "strings" ) //go:embed kitty/constants.py @@ -19,6 +22,7 @@ var VersionString string var Version VersionType var VCSRevision string var WebsiteBaseUrl string +var DefaultPager []string func init() { verpat := regexp.MustCompile(`Version\((\d+),\s*(\d+),\s*(\d+)\)`) @@ -47,5 +51,15 @@ func init() { if matches[1] == "" { panic(fmt.Errorf("Failed to find the website base url")) } - + pager_pat := regexp.MustCompile(`default_pager_for_help\s+=\s+\((.+?)\)`) + matches = pager_pat.FindStringSubmatch(raw) + if matches[1] == "" { + panic(fmt.Errorf("Failed to find the default_pager_for_help")) + } + text := strings.ReplaceAll("[" + matches[1] + "]", "'", "\"") + err = json.Unmarshal([]byte(text), &DefaultPager) + if err != nil { + fmt.Fprintln(os.Stderr, "Failed to unmarshal default pager text:", text) + panic(err) + } }