diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index 4bb6e3136..3a8904002 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -1,5 +1,6 @@ #! bash oh-my-bash.module +_omb_module_require lib:omb-util _omb_module_require lib:omb-deprecate _omb_module_require lib:omb-prompt-colors @@ -101,7 +102,9 @@ function _omb_prompt_format { local __suffix=${3#*:}_SUFFIX; __suffix=${!__suffix-} # deprecate name __format=${__prefix//'%'/'%%'}%s${__suffix//'%'/'%%'} fi - printf -v "$1" "$__format" "$2" + local REPLY + _omb_string_escape_prompt "$2" + printf -v "$1" "$__format" "$REPLY" } function _omb_prompt_git { diff --git a/lib/omb-util.sh b/lib/omb-util.sh new file mode 100644 index 000000000..a93fecfa0 --- /dev/null +++ b/lib/omb-util.sh @@ -0,0 +1,14 @@ +#! bash oh-my-bash.module + +function _omb_string_escape_prompt { + REPLY=$1 + local specialchars='\`$' + if [[ $REPLY == ["$specialchars"] ]]; then + local i n=${#specialchars} a b + for ((i=0;i