How to make less show the filename

less

I often have multiple terminal windows opened with less (eg comparing various log files). I forget which file is which. Is there a similar command to ^G in vi which displays the name of the file currently being viewed?

Best Answer

Compatible: ^G. Easy to type: =. Less copied several key bindings from vi, including this one. This displays the file name (the path that you passed on the less command line) and the position in the file.

You can have this information permanently by calling less with the -M option. Include -M in the LESS environment variable. You can set this variable in your ~/.profile, ~/.pam_environment or wherever you define environment variables. Alternatively, you can set LESS by using lesskey to produce the configuration file ~/.less which is read by less.

Related Question