2
1
Is it possible to map function keys (F1-F12) in less
with lesskey
?
This doesn't seem to work:
#command
F1 forw-line
2
1
Is it possible to map function keys (F1-F12) in less
with lesskey
?
This doesn't seem to work:
#command
F1 forw-line
2
Historically, terminals use escaped sequences for functions keys, cursor keys and more. The termcap and terminfo facilities help to deal with the variations across terminals.
First you need to determine what your terminal sends when you hit F1, in bash
you can do:
printf "%q\n" "
CtrlV F1"
Within the second pair of quotes you type Ctrl+V to cause the next keystroke to be treated literally (verbatim), and then F1. On my terminal (rxvt) I see
$'\E[11~'
so my F1 sequence is escape [ 11 ~
, so into .lesskey
should go
#command
\e[11~ forw-line
run lesskey
to update, and now F1 will invoke that command.
infocmp
is another way to see how your terminal is set up, e.g.
infocmp -L1 rxvt | grep key_f1=
See Stéphane Chazelas answer here for more details on that, though less
doesn't use readline
, configuring readline requires a similar understanding.