编辑 /etc/inputrc 文件,设置全局readline配置,加入以下指令:
# I like vi mode,设置默认的编辑模式为vi
set editing-mode vi
# emacs mode settings,emacs模式配置指令
$if mode=emacs
# ...
# vi mode settings,vi模式配置指令
$else
# Ctrl+l : clear screen ,清屏
"\C-l": clear-screen
# Ctrl+p : previous-history,前一条历史命令
"\C-p": previous-history
# Ctrl+n : next-history,后一条历史命令
"\C-n": next-history
# Ctrl+e : press esc,ESC键,你懂的
"\C-e": "\e"
$endif
说明:
/etc/inputrc 文件是 libreadline 的全局配置文件,个人的配置文件为 ~/.inputrc
关于libreadline 的介绍如下:
The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands.
The history facilites are also placed into a separate library, the History library, as part of the build process. The History library may be used without Readline in applications which desire its capabilities.
Readline is free software, distributed under the terms of the GNU General Public License, version 3. This means that if you want to use Readline in a program that you release or distribute to anyone, the program must be free software and have a GPL-compatible license. If you would like advice on making your license GPL-compatible, contact licensing@gnu.org.
bash就是通过readline library 来提供命令行的方便快捷的编辑功能,包括各种用于命令编辑的快捷键,命令历史操作等功能。
阅读(646) | 评论(0) | 转发(0) |