0
declare __host='\[\e[30;102m\] \h \[\e[0m\]';
declare __dir='\[\e[1;97;44m\] \w \[\e[22m\]';
declare __arrow='\[\e[1m\]▸ \[\e[0m\]';

function __git_status() {
  local info;
  info=$(__git_info) && printf '\e[30;43m%s' "$info";
}

PS1="$__host$__dir"'$(__git_status)'"$__arrow ";

When I go to perform multi-line commands, they wrap back to the starting line. I'm certain it has something to do with escapes in my PS1. I've tried nearly everything I can think of and ended up no where. I'd appreciate any and all help.

The goal is to have the arrow's background color take the color from the previous section. If I'm in a git repo, it should be yellow. If I'm not, it should be blue.

enter image description here enter image description here

0

The solution was to change:

info=$(__git_info) && printf '\e[30;43m%s' "$info"

to

info=$(__git_info) && printf '\1\e[30;43m\2%s' "$info"

This is because bash internally replaces the prompting special characters [ and ] with ASCII 1 and 2 before my __git_status function is executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.