$somevar 可以对美元符号进行转义,避免在设置提示符的命令中对该变量进行解释,而是在显示提示符时对其进行解释。
The phrase \$somevar escapes the dollar sign, avoiding interpretation of the variable in the command where the prompt is set. Instead, the interpretation occurs whenever the prompt is drawn.
需要对一些特殊字符进行转义,否则shell会解释它们。
Some special characters, which would otherwise be interpreted by the shell, need to be escaped.
如果希望在每次显示提示符时都动态展开变量,则必须在设置提示符时对它的解释进行转义。
If you want to expand a variable dynamically each time the prompt is rendered, you must escape its interpretation when set. Let's look at just that.
应用推荐