【发布时间】:2014-03-06 12:33:11
【问题描述】:
来自GNU readline and key bindings的代码:
#include <stdio.h>
#include <readline/readline.h>
int my_cool_readline_func (int count, int key) {
printf ("key pressed: %d\n", key);
rl_on_new_line ();
return 0;
}
int main(void) {
rl_command_func_t my_cool_readline_func;
rl_bind_key ('\t', my_cool_readline_func);
rl_bind_key (27, my_cool_readline_func); /* ascii code for ESC */
rl_bind_keyseq ("\\C-a", my_cool_readline_func);
while (1) {
char *line = readline ("rl> ");
}
}
是否可以在 bash 命令行中使用这种自定义的 readline 函数?
例如,我已经尝试过这些(当然,自定义函数可能要复杂得多):
bind '"\C-t" beginning-of-line shell-kill-word'
bind '"\C-t" beginning-of-line, shell-kill-word'
bind '"\C-t" beginning-of-line; shell-kill-word'
它们都不起作用。
【问题讨论】: