【发布时间】:2018-09-23 11:43:41
【问题描述】:
bash manual 表示,在提示符中,任何非打印字符序列都应括起来,如:\[this\]:
\[ Begin a sequence of non-printing characters.
This could be used to embed a terminal control sequence into the prompt.
\] End a sequence of non-printing characters.
给定一个要包含在提示中的字符串,我如何自动转义所有 ANSI 控件/颜色代码,以使提示在所有情况下都正确显示/换行?
区分:这里我假设已经产生了一个带有ANSI控制码的字符串。
This related question 假定可以通过编辑字符串的生成函数来插入分隔符。
【问题讨论】: