山不在高,有仙则灵,水不在深,有龙则灵
玩转键盘系列:
#map home 键,end 键 为到行首,行尾, 使命令行编辑符合我们通常的习惯
"\e[1~": beginning-of-line
"\e[4~": end-of-line
其中前面怪怪的双引号括住的部分是键盘序列。 在bash 下按ctrl-v, 再按控制键可以显示出该控制键序列
冒号后面的命令,可用bind -p 查看到具体的名称。 不要敲错字母了哈。
#定义
#哈哈,实现一键执行一个批命令(也可以让它执行你的sh 命令), 从此最常用的键盘操作就是简单的敲敲打打了。
# 这行命令,是我最常用的Android 编译命令, 其输出err.err 可以由vim 调入来快速修改错误
"\e[18~": "mm >err.err 2>&1 1>/dev/null\ncat err.err\n"
bochs 太自虐了,每次让我敲击u switch-mode, 终于想到了这个方法。功能键
"\eOQ":"b 0\nu switch-mode\nc\n"
#忽略大小写,显示可能的文件列表,方便我们在命令行输入
set completion-ignore-case on
set show-all-if-ambiguous on
其中那个长长的选项名称,可以用bind -v 命令查看。 是readline 的内置选项。
另实例:
F3 的按键序列
"\eOR":"grep -nr --include=*.c --include=*.{h,cpp} "
# F7 的按键序列
"\e[18~":"grep -nr --exclude=.svn "
~
关于按键序列,用cat命令,再敲击功能建也可以显示在终端上.(前面说的bash下按ctrl-v再击键也可以)
用bind -s 可以看到所定义的键盘宏, bind -S 也可以,只是显示方式不同, C-x C-r 可以重新加载.inputrc
bind -p 研究一下默认的readline 键盘CTRL 健bind 内容, 会对按键快速输入有不少帮助的.
bind -p |grep -v "^#" |grep -v self-insert |grep -v do-lower |grep -v digital > 1.txt
cat 1.txt |grep "^\"\\\C" |sort 控制键Control
"\C-a": beginning-of-line
"\C-?": backward-delete-char
"\C-b": backward-char
"\C-]": character-search
"\C-d": delete-char
"\C-e": end-of-line
"\C-f": forward-char
"\C-g": abort
"\C-h": backward-delete-char
"\C-i": complete
"\C-j": accept-line
"\C-k": kill-line
"\C-l": clear-screen
"\C-m": accept-line
"\C-n": next-history
"\C-o": operate-and-get-next
"\C-p": previous-history
"\C-q": quoted-insert
"\C-r": reverse-search-history
"\C-@": set-mark
"\C-s": forward-search-history
"\C-t": transpose-chars
"\C-_": undo
"\C-u": unix-line-discard
"\C-v": quoted-insert
"\C-w": unix-word-rubout
"\C-x\C-?": backward-kill-line
"\C-x\C-e": edit-and-execute-command
"\C-x\C-g": abort
"\C-x\C-r": re-read-init-file
"\C-x\C-u": undo
"\C-x\C-v": display-shell-version
"\C-x\C-x": exchange-point-and-mark
"\C-xe": call-last-kbd-macro
"\C-x)": end-kbd-macro
"\C-xg": glob-list-expansions
"\C-x*": glob-expand-word
"\C-x!": possible-command-completions
"\C-x/": possible-filename-completions
"\C-x@": possible-hostname-completions
"\C-x~": possible-username-completions
"\C-x$": possible-variable-completions
"\C-x(": start-kbd-macro
"\C-y": yank