Linux command
lesskey 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile
lesskey
Compile
lesskey [path/to/lesskey_file]
Compile
lesskey -o [path/to/output] [path/to/lesskey_file]
lesskey -V
说明
lesskey is used to specify or customize key bindings for the less pager. It reads a source file containing key binding definitions and compiles it into a binary file that less reads at startup. The default input file is ~/.lesskey and the default output file is ~/.less. The lesskey source file can contain up to four sections, each introduced by a header line: #command for key bindings, #line-edit for editing behavior at the search prompt, #env for environment variables, and #stop to mark end of file. In the #command section, each line maps a key sequence to a less action. Keys can be specified as literal characters, control characters (^X), escape sequences (\e), or special keys like arrows (\ku, \kd, \kr, \kl), page up/down (\kU, \kD), home (\kh), end (\ke), and delete (\kx). The #line-edit section controls behavior at the search and command prompts with actions like forw-complete, back-complete, delete, backspace, home, end, up, down, and abort. The #env section sets environment variables that less will see at startup, such as LESS for default options and LESSCHARSET for character set configuration.
参数
- -o _file_, --output=_file_
- Specify the output file for the compiled binary key binding file. Defaults to ~/.less
- -V, --version
- Display the version number of lesskey
- --
- Marks the end of options; useful if the input filename begins with a dash
FAQ
What is the lesskey command used for?
lesskey is used to specify or customize key bindings for the less pager. It reads a source file containing key binding definitions and compiles it into a binary file that less reads at startup. The default input file is ~/.lesskey and the default output file is ~/.less. The lesskey source file can contain up to four sections, each introduced by a header line: #command for key bindings, #line-edit for editing behavior at the search prompt, #env for environment variables, and #stop to mark end of file. In the #command section, each line maps a key sequence to a less action. Keys can be specified as literal characters, control characters (^X), escape sequences (\e), or special keys like arrows (\ku, \kd, \kr, \kl), page up/down (\kU, \kD), home (\kh), end (\ke), and delete (\kx). The #line-edit section controls behavior at the search and command prompts with actions like forw-complete, back-complete, delete, backspace, home, end, up, down, and abort. The #env section sets environment variables that less will see at startup, such as LESS for default options and LESSCHARSET for character set configuration.
How do I run a basic lesskey example?
Run `lesskey` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -o _file_, --output=_file_ do in lesskey?
Specify the output file for the compiled binary key binding file. Defaults to ~/.less