颜色失败反向搜索

Ste*_*nny 5 shell colors bash terminal readline

我可以输入一个命令:

$ echo hello
hello
Run Code Online (Sandbox Code Playgroud)

然后使用 Ctrl+R 搜索它:

(reverse-i-search)`h': echo hello
Run Code Online (Sandbox Code Playgroud)

然后有时搜索会失败:

(failed reverse-i-search)`hz': echo hello
Run Code Online (Sandbox Code Playgroud)

我可以以某种方式为显示的“失败的反向搜索”部分着色吗?我更喜欢红色文本与普通白色文本的对比。这样我就可以快速判断搜索失败了。

Ste*_*nny 1

正如czvtools 所指出的,“反向搜索失败”会发出警报。您可以创建一个视觉铃声而不是常规铃声。创建一个文件“xterm-vb.terminfo”:

xterm-vb|red visible bell,
# \e7                   save current cursor position
# \e[40A                up 40 lines
# \e[80C                move right 80 spaces
# \e[4D                 move left 4 spaces
# \e[5;30;41mERROR\e[m  bright background; foreground black; background red
# \e8                   restore cursor to position of last save_cursor
  flash=\e7\e[40A\e[80C\e[4D\e[5;30;41mERROR\e[m\e8,
  use=xterm,
Run Code Online (Sandbox Code Playgroud)

编译并安装文件:

tic xterm-vb.terminfo
Run Code Online (Sandbox Code Playgroud)

将行添加到“~/.profile”或类似内容:

TERM=xterm-vb
Run Code Online (Sandbox Code Playgroud)

将行添加到“~/.inputrc”:

set bell-style visible
Run Code Online (Sandbox Code Playgroud)