22

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?

25

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.

  • Note that if you use less +F -M <filename> it won't show the filename until you quit the follow. (+F = --follow-name) – phyatt Jan 13 '16 at 20:13
  • 1
    Awesome answer — I did not know about lesskey or about the -M option! – Noah Sussman May 27 '16 at 7:07
4

I just found -M (show more verbose status line), which seems to do what I want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.