Soluzione
Una versione meno manuale del knitatoms' answer combinato con Alex Marteilli's answer funziona abbastanza bene: passare l'opzione +Gg
per less
tramite l'opzione cercapersone.
Ad esempio, provare
man -P 'less -s -M +Gg' man
Questo può essere effettuato in modo permanente mettendo
export MANPAGER='less -s -M +Gg'
in uno dei file di configurazione della shell (sopra sintassi è per Bash e ZSH). Ora, ad esempio, man man
visualizza la percentuale desiderata come !
Attenzione
Si dovrebbe non mettere il +Gg
nella variabile LESS
! Ad esempio, facendo
export LESS='-M +Gg'
causerà problemi durante la lettura di file molto grandi. Ad esempio,
yes | LESS='-M +Gg' less
non funziona molto bene ...
Spiegazione
Come altre risposte hanno spiegato, il problema è che non si può dire less
quale percentuale nel file che si sta fino a quando non sa per quanto tempo il file è, e non legge fino alla fine del file per impostazione predefinita quando legge da una pipe.
Dalla sezione OPTIONS
di man less
:
+ If a command line option begins with +, the remainder of that
option is taken to be an initial command to less. For exam‐
ple, +G tells less to start at the end of the file rather than
the beginning, and +/xyz tells it to start at the first occur‐
rence of "xyz" in the file. As a special case, +<number> acts
like +<number>g; that is, it starts the display at the speci‐
fied line number (however, see the caveat under the "g" com‐
mand above). If the option starts with ++, the initial com‐
mand applies to every file being viewed, not just the first
one. The + command described previously may also be used to
set (or change) an initial command for every file.
Le g
significa "tornare all'inizio del file".
Dal man man
:
-P pager, --pager=pager
Specify which output pager to use. By default, man uses pager
-s. This option overrides the $MANPAGER environment variable,
which in turn overrides the $PAGER environment variable. It
is not used in conjunction with -f or -k.
The value may be a simple command name or a command with argu‐
ments, and may use shell quoting (backslashes, single quotes,
or double quotes). It may not use pipes to connect multiple
commands; if you need that, use a wrapper script, which may
take the file to display either as an argument or on standard
input.
Questo sembra infinitamente ricorsivo. cioè la chiamata all'uomo all'interno della funzione chiamerà la funzione 'man', non l'eseguibile' man'. – Yuliy
Ho aperto una nuova discussione per il nuovo problema: http://stackoverflow.com/questions/1053707/unable-to-make-a-shell-function-in-bash-zsh –
@Yuliy: Hai fatto la mossa cruciale. Abbiamo bisogno di dissipare la funzione uomo in qualche modo impostando una variabile fittizia su di esso, forse. –