From 11e8ad4bdce9979eb871635bf455213788de5e05 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 26 Aug 2015 13:39:39 +0100 Subject: Bypass PS1s conversion of \[ In PS1 you need to escape non-printing characters, like the color codes. The standard way is wrapping it in `\[` and `\]`. But for a dynamic prompt, i.e. one that renders the results of a function every time the prompt renders, that `\[` will be output as literals. To fix this we bypass the conversion and wrap our non-printing characters in the desired characters directly: `\[` -> `\x01` `\]` -> `\x02` --- test-commits.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test-commits.sh') diff --git a/test-commits.sh b/test-commits.sh index 0cca0e5..95addf9 100755 --- a/test-commits.sh +++ b/test-commits.sh @@ -374,9 +374,9 @@ test_zsh_and_bash_local_commits() { local zsh_both="%{[yellow]%}⇵%{%}" local zsh_down="%{[red]%}↓%{%}" - printf -v bash_up "\033[1;32m↑\033[0m" - printf -v bash_both "\033[1;33m⇵\033[0m" - printf -v bash_down "\033[1;31m↓\033[0m" + printf -v bash_up "\x01\033[1;32m\x02↑\x01\033[0m\x02" + printf -v bash_both "\x01\033[1;33m\x02⇵\x01\033[0m\x02" + printf -v bash_down "\x01\033[1;31m\x02↓\x01\033[0m\x02" cd_to_tmp "remote" -- cgit v1.2.3