问题
I seem to be running into a situation with my custom Bash Prompt, very similar to this one here:
Bash prompt line wrapping issue
I'm thinking escaping might be my issue (as mentioned in the url above) I've tried moving things around and removing my brackets, but all that does is mess up my bash prompt. Is someone able to lend a hand with this:
"What! \[\e[1;33m\]\w\[\e[m\]\[\e[37m\]\$(parse_git_branch)\[\033[00m\] \e[m\]$ "
回答1:
All non-printing segments in the must be surrounded by \[...\]
and all printing segments must not be surrounded by those.
You have at least one space inside \[...\]
near the end.
You also have a large number of unclosed \[
(count your matched pairs).
Using variables for the color codes themselves (as in the linked question) will simplify seeing where the escapes need to go in the prompt itself. (Though the linked question puts the prompt escapes in the variables also which complicates seeing what's going on a bit to my mind.)
来源:https://stackoverflow.com/questions/30309800/bash-prompt-wrapping-issue