LinuxGem
此处为老的 LinuxGem,新版 LinuxGem 请移步 www.linuxgem.org

改变 bash 命令编辑风格

galeki posted @ 2007年10月25日 02:04 in Bash 和它的朋友们 with tags 风格 bash , 3799 阅读

转自 zhaidongplus 的 Blog: http://blog.linuxgem.org/zhaidongplus/show/506.html

大家在终端中敲命令的时候,或许都用过Ctrl A(移动光标到行首)、Ctrl U(删除光标至行首的内容)等快捷键吧。这些编辑快捷键都属于emacs的编辑风格,bash默认的命令编辑风格就是emacs式的,我们也可以把编辑风格改为vi式的: 

zhaidong@gentoo ~ $ set -o    #查看bash的设置选项
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off
zhaidong@gentoo ~ $ set -o vi     #开启vi选项

现在,在bash中敲命令时为vi的插入模式。按下Esc,就进入了命令模式,很多vi的编辑命令都可以使用。

如果喜欢vi式的bash命令编辑风格,我们可以把set -o vi加入~/.bashrc

zhaidong@gentoo ~ $ echo "set -o vi">>~/.bashrc
vvoody 说:
2008年9月30日 03:34

显然Emacs按键方便嘛^_^

anonymous 说:
2023年10月08日 21:47

Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... Bathroom Remodeling Orlando

anonymous 说:
2023年11月22日 17:48

Initial You got a awesome blog .I determination be involved in plus uniform minutes. i view you got truly very functional matters , i determination be always checking your blog blesss. Virtual CPA Services


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter