在Bash的Vi命令行编辑中区分命令模式和插入模式的方法 [英] The way to distinguish command-mode and insert-mode in Bash's Vi command line editing

查看:141
本文介绍了在Bash的Vi命令行编辑中区分命令模式和插入模式的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当vi模式下的bash切换到插入模式时,我总是有点困惑,因为它没有提供任何有关使用模式(命令或编辑)的提示. 有什么办法可以区分MOD吗?可能是自动更改光标颜色还是类似的东西?

I'm always little bit confused when bash in vi-mode is switched to insert-mode, because it doesn't give any tip about used mode (command or edit). Is there any way to distinguish mods? May be automatic change of cursor color or something like that?

推荐答案

添加以下内容:

set show-mode-in-prompt on

在插入模式下,此提示将在提示符前以 + 为前缀,在bash 4.3中的命令模式下,其将以:为前缀

this will prefix your prompt with + while in insert-mode, and : while in command mode in bash 4.3

在最新版本的bash 4.4中,默认情况下,您将获得提示以(ins)"或(cmd)"为前缀的提示.但是,您可以更改它:

in the latest version of bash 4.4, you will instead get a prompt prefixed with "(ins)" or "(cmd)" by default. but, you can change that:

set vi-ins-mode-string "+"
set vi-cmd-mode-string ":"

此外,您可以使用颜色代码,例如'\ e [1; 31m,但将其用'\ 1'和'\ 2'包围以使阅读行保持高兴:

also, you can use color codes like '\e[1;31m', but surround them with '\1' and '\2' to keep readline happy:

set vi-cmd-mode-string "\1\e[1;31m\2:\1\e[0m\2"

这篇关于在Bash的Vi命令行编辑中区分命令模式和插入模式的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆