Repository: xonsh/xonsh

Issue:
"Invalid ANSI color sequence" warning on startup
`xonfig` output:
```
$ xonfig
+------------------+-----------------+
| xonsh            | 0.9.9           |
| Python           | 3.7.4           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 2.0.9           |
| shell type       | prompt_toolkit2 |
| pygments         | 2.4.2           |
| on posix         | True            |
| on linux         | False           |
| on darwin        | True            |
| on windows       | False           |
| on cygwin        | False           |
| on msys2         | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+
```

Giving xonsh another try, looks like there are still `LS_COLORS` issues. Here's what I get on startup:

```
$ xonsh
/usr/local/Cellar/xonsh/0.9.9/libexec/lib/python3.7/site-packages/xonsh/__amalgam__.py:7117: RuntimeWarning: Invalid ANSI color sequence "target", using "NO_COLOR" instead.
  warnings.warn(msg, RuntimeWarning)
```

I gave my LS_COLORS values [last time this came up](https://github.com/xonsh/xonsh/issues/3034). Please let me know if I can do anything to help diagnose. Thanks.

Discussion:

Patch:
diff --git a/news/target-color.rst b/news/target-color.rst
new file mode 100644
index 00000000..61f37ea8
--- /dev/null
+++ b/news/target-color.rst
@@ -0,0 +1,25 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* Implemented ``'target'`` psuedo-color in ``$LS_COLORS`` for link coloring based
+  off of the link target. This was causing issues on some systems where this is
+  the default.
+
+**Security:**
+
+* <news item>
diff --git a/xonsh/environ.py b/xonsh/environ.py
index 305f585c..8bc1131e 100644
--- a/xonsh/environ.py
+++ b/xonsh/environ.py
@@ -184,7 +184,8 @@ def to_debug(x):
 
 class LsColors(cabc.MutableMapping):
     """Helps convert to/from $LS_COLORS format, respecting the xonsh color style.
-    This accepts the same inputs as dict().
+    This accepts the same inputs as dict(). The link ``target`` is represented
+    by the special ``"TARGET"`` color.
     """
 
     default_settings = {
@@ -368,7 +369,12 @@ class LsColors(cabc.MutableMapping):
                     key
                     + "="
                     + ";".join(
-                        [ansi_color_name_to_escape_code(v, cmap=style) for v in val]
+                        [
+                            "target"
+                            if v == "TARGET"
+                            else ansi_color_name_to_escape_code(v, cmap=style)
+                            for v in val
+                        ]
                     )
                     for key, val in sorted(self._d.items())
                 ]
@@ -408,10 +414,13 @@ class LsColors(cabc.MutableMapping):
             key, eq, esc = item.partition("=")
             if not eq:
                 # not a valid item
-                continue
-            data[key] = ansi_color_escape_code_to_name(
-                esc, "default", reversed_style=reversed_default
-            )
+                pass
+            elif esc == "target":
+                data[key] = ("TARGET",)
+            else:
+                data[key] = ansi_color_escape_code_to_name(
+                    esc, "default", reversed_style=reversed_default
+                )
         obj._d = data
         return obj
 


Test patch:
diff --git a/tests/test_environ.py b/tests/test_environ.py
index 5ba7d201..88b09992 100644
--- a/tests/test_environ.py
+++ b/tests/test_environ.py
@@ -19,6 +19,7 @@ from xonsh.environ import (
     DEFAULT_VALUES,
     default_env,
     make_args_env,
+    LsColors,
 )
 
 from tools import skip_if_on_unix
@@ -292,3 +293,9 @@ def test_delitem_default():
     assert env[a_key] == a_value
     del env[a_key]
     assert env[a_key] == a_value
+
+
+def test_lscolors_target():
+    lsc = LsColors.fromstring("ln=target")
+    assert lsc["ln"] == ("TARGET",)
+    assert lsc.detype() == "ln=target"