Solution
Une version moins manuelle de knitatoms' answer combiné avec Alex Marteilli's answer fonctionne très bien: passer l'option +Gg
à less
via son option pager.
Par exemple, essayez
man -P 'less -s -M +Gg' man
Ceci peut être réalisé de façon permanente en mettant
export MANPAGER='less -s -M +Gg'
dans l'un de vos fichiers de configuration shell (ci-dessus pour la syntaxe est Bash et ZSH). Maintenant, par exemple, man man
affiche le pourcentage que vous voulez !
Avertissement
Vous devriez pas mettre la +Gg
dans la variable LESS
! Par exemple, faire
export LESS='-M +Gg'
causera des problèmes lors de la lecture des fichiers très volumineux. Par exemple,
yes | LESS='-M +Gg' less
ne fonctionne pas très bien ...
Explication
Comme d'autres réponses ont expliqué, le problème est que less
ne peut pas dire ce que pour cent dans le fichier que vous êtes jusqu'à ce qu'il sache combien de temps le fichier est, et il ne lit pas à la fin du fichier par défaut lors de la lecture à partir d'un tuyau.
Dans la section OPTIONS
de 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.
Les g
signifie "retour au début du fichier".
De l'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.
Cela semble infiniment récursif. c'est-à-dire que l'appel à l'homme à l'intérieur de la fonction appellera la fonction "homme", pas l'exécutable "homme". – Yuliy
J'ai ouvert un nouveau fil pour le nouveau problème: http://stackoverflow.com/questions/1053707/unable-to-make-a-shell-function-in-bash-zsh –
@Yuliy: Vous avez fait bouger le crux. Nous devons déconnecter la fonction de l'homme d'une façon ou d'une autre en définissant une variable fictive, peut-être. –