fix mangled prompts

this pull requests fixes a few issues I had with this pull request:

1. error message printed when no configured upstream branch
2. 256 color code used in precmd doesn't work on my terminal
3. preexec hook mangles output when the command itself contains escape
sequences
4. cursor position isn't restored correctly when you have already began
typing something before the async command executes