Repository: xonsh/xonsh

Issue:
[color] in .gitconfig should be stripped in the prompt branch functions
In clean install with no `.xonshrc`, when I change into a git repo, my prompt looks like:

![prompt](https://i.imgur.com/ZFOPSOj.png)

Is there some setting I'm missing somewhere?

## xonfig

<details>

```
+------------------+----------------------+
| xonsh            | 0.9.13.dev1          |
| Git SHA          | 9f7ccc65             |
| Commit Date      | Oct 15 17:14:50 2019 |
| Python           | 3.7.6                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.0                |
| shell type       | prompt_toolkit2      |
| pygments         | 2.5.2                |
| on posix         | True                 |
| on linux         | True                 |
| distro           | ubuntu               |
| on darwin        | False                |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
+------------------+----------------------+
```


</details>

## Expected Behavior
I think something like this (without the ansi escape codes):
```
mcrowe@mike-XPS-15-9560 ~/.dotfiles/bash_it [master] $
```


Discussion:

Patch:
diff --git a/news/3427-fix-vc-prompt-color.rst b/news/3427-fix-vc-prompt-color.rst
new file mode 100644
index 00000000..f9b3c559
--- /dev/null
+++ b/news/3427-fix-vc-prompt-color.rst
@@ -0,0 +1,24 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+-  `[color] in .gitconfig (#3427) <https://github.com/xonsh/xonsh/issues/3427>`_ now stripped from {curr\_branch} 
+
+  - `Before <https://i.imgur.com/EMhPdgU.png>`_
+  - `After <https://i.imgur.com/sJiqgsb.png>`_
+
+
diff --git a/xonsh/prompt/vc.py b/xonsh/prompt/vc.py
index abd51a88..91f9613a 100644
--- a/xonsh/prompt/vc.py
+++ b/xonsh/prompt/vc.py
@@ -8,8 +8,16 @@ import queue
 import builtins
 import threading
 import subprocess
+import re
 
 import xonsh.tools as xt
+from xonsh.lazyasd import LazyObject
+
+RE_REMOVE_ANSI = LazyObject(
+    lambda: re.compile(r"(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]"),
+    globals(),
+    "RE_REMOVE_ANSI",
+)
 
 
 def _get_git_branch(q):
@@ -50,6 +58,9 @@ def get_git_branch():
     t.join(timeout=timeout)
     try:
         branch = q.get_nowait()
+        # branch = RE_REMOVE_ANSI.sub("", branch or "")
+        if branch:
+            branch = RE_REMOVE_ANSI.sub("", branch)
     except queue.Empty:
         branch = None
     return branch


Test patch:
diff --git a/tests/test_prompt.py b/tests/test_prompt.py
index d28e4b71..ed979d6e 100644
--- a/tests/test_prompt.py
+++ b/tests/test_prompt.py
@@ -241,6 +241,21 @@ def test_vc_get_branch(test_repo, xonsh_builtins):
     obs = getattr(vc, fun)()
     if obs is not None:
         assert obs == VC_BRANCH[test_repo["name"]]
+        if test_repo["name"] == "git":
+            with open("{}/.git/config".format(test_repo["dir"]), "a") as gc:
+                gc.write(
+                    """
+[color]
+    branch = always
+    interactive = always
+[color "branch"]
+    current = yellow reverse
+"""
+                )
+            obs = getattr(vc, fun)()
+            if obs is not None:
+                assert obs == VC_BRANCH[test_repo["name"]]
+                assert not obs.startswith(u"\u001b[")
 
 
 def test_current_branch_calls_locate_binary_for_empty_cmds_cache(xonsh_builtins):
@@ -253,7 +268,7 @@ def test_current_branch_calls_locate_binary_for_empty_cmds_cache(xonsh_builtins)
 
 
 def test_current_branch_does_not_call_locate_binary_for_non_empty_cmds_cache(
-    xonsh_builtins
+    xonsh_builtins,
 ):
     cache = xonsh_builtins.__xonsh__.commands_cache
     xonsh_builtins.__xonsh__.env = DummyEnv(VC_BRANCH_TIMEOUT=1)