Textualize / rich-cli

Rich-cli is a command line toolbox for fancy output in the terminal
https://www.textualize.io
MIT License
3.04k stars 75 forks source link

RFE: Allow spacebar to advance pager #19

Open larsks opened 2 years ago

larsks commented 2 years ago

Every time I use --pager my fingers bang helplessly on the spacebar until I remember that I have to use pageup/pagedown, etc. Any chance you could allow the spacebar to advance the pager as well so that the behavior matches other common pagers?

ibeex commented 2 years ago

It would be great if you can add also vi style navigation and search...

ernstki commented 2 years ago

rich-cli's pager is pretty neat, and I'm not knocking it. But on any platform other than straight Windows (without WSL or Cygwin), you already have a pager that does all the things you're asking for here.

Adding --force-terminal every time and piping into less -R is a lot to ask, but this is a great use for shell functions:

# simple wrapper, assuming Bash shell…
richp() { command rich --force-terminal "$@" | less -RX; }
# less -RX → process terminal escapes (e.g., colors), don't clear screen on quit

# handle redirection/piped input as well
richp() {
    local stdin=-
    [[ -t 0 ]] && stdin=
    command rich --force-terminal $stdin "$@" | less -RX
}

Examples:

README=https://raw.githubusercontent.com/Textualize/rich-cli/main/README.md
curl $README | richp -m
richp $README

# other options pass through just fine
richp $README -d 0,$(((COLUMNS-80)/2))
jdsalmonson commented 2 years ago

It would be great to have emacs-style navigation as well. Perhaps there can be a configuration file (say ".richrc") that stores the user's configuration.