Repository: xonsh/xonsh

Issue:
How to disable 'skipping application of alias' message and let xonsh aliases take precedence
<!--- Provide a general summary of the issue in the Title above -->
<!--- If you have a question along the lines of "How do I do this Bash command in xonsh"
please first look over the Bash to Xonsh translation guide: http://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->

## xonfig
<!--- Please post the output of the `xonfig` command (run from inside xonsh) so we know more about your current setup -->
```
+------------------+-----------------+
| xonsh            | 0.7.7           |
| Python           | 3.6.5           |
| PLY              | 3.9             |
| have readline    | True            |
| prompt toolkit   | 2.0.4           |
| shell type       | prompt_toolkit2 |
| pygments         | None            |
| 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 |
+------------------+-----------------+
```

## Expected Behavior
<!--- Tell us what should happen -->
I have just started using xonsh and would like to make it my main shell, but still be able to use bash aliases in both places. Ideally, xonsh should ignore any bash aliases that have the same name. If an alias has been defined in xonsh, I would like it to take precedence over any foreign aliases.

I don't want to see this error message every time I open the shell, and the `--overwrite-alias` option seems to do the opposite of what I want. Perhaps the ideal solution is to only print this message when `XONSH_DEBUG` is set.


## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
<!--- If part of your bug report is a traceback, please first enter debug mode before triggering the error
To enter debug mode, set the environment variable `XONSH_DEBUG=1` _before_ starting `xonsh`.  
On Linux and OSX, an easy way to to do this is to run `env XONSH_DEBUG=1 xonsh` -->
I get this message every time I open xonsh:
```
Skipping application of 'ls' alias from 'bash' since it shares a name 
with an existing xonsh alias. Use "--overwrite-alias" option to 
apply it anyway.
```

## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->
Open xonsh with bash sourced as a foreign shell, since bash usually has `alias ls='ls --color=auto'` defined by default.


Discussion:

Resolving patch:
diff --git a/xonsh/aliases.py b/xonsh/aliases.py
--- a/xonsh/aliases.py
+++ b/xonsh/aliases.py
@@ -260,6 +260,13 @@ def _SOURCE_FOREIGN_PARSER():
         help="flag for whether or not sourced aliases should "
         "replace the current xonsh aliases.",
     )
+    parser.add_argument(
+        "--suppress-skip-message",
+        default=None,
+        action="store_true",
+        dest="suppress_skip_message",
+        help="flag for whether or not skip messages should be suppressed.",
+    )
     parser.add_argument(
         "--show",
         default=False,
@@ -280,7 +287,13 @@ def _SOURCE_FOREIGN_PARSER():
 
 def source_foreign(args, stdin=None, stdout=None, stderr=None):
     """Sources a file written in a foreign shell language."""
+    env = builtins.__xonsh_env__
     ns = _SOURCE_FOREIGN_PARSER.parse_args(args)
+    ns.suppress_skip_message = (
+        env.get("FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE")
+        if ns.suppress_skip_message is None
+        else ns.suppress_skip_message
+    )
     if ns.prevcmd is not None:
         pass  # don't change prevcmd if given explicitly
     elif os.path.isfile(ns.files_or_code[0]):
@@ -315,7 +328,6 @@ def source_foreign(args, stdin=None, stdout=None, stderr=None):
             msg += "xonsh: error: Possible reasons: File not found or syntax error\n"
             return (None, msg, 1)
     # apply results
-    env = builtins.__xonsh_env__
     denv = env.detype()
     for k, v in fsenv.items():
         if k in denv and v == denv[k]:
@@ -332,11 +344,15 @@ def source_foreign(args, stdin=None, stdout=None, stderr=None):
             continue  # no change from original
         elif ns.overwrite_aliases or k not in baliases:
             baliases[k] = v
+        elif ns.suppress_skip_message:
+            pass
         else:
             msg = (
                 "Skipping application of {0!r} alias from {1!r} "
                 "since it shares a name with an existing xonsh alias. "
                 'Use "--overwrite-alias" option to apply it anyway.'
+                'You may prevent this message with "--suppress-skip-message" or '
+                '"$FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE = True".'
             )
             print(msg.format(k, ns.shell), file=stderr)
 
diff --git a/xonsh/environ.py b/xonsh/environ.py
--- a/xonsh/environ.py
+++ b/xonsh/environ.py
@@ -185,6 +185,7 @@ def DEFAULT_ENSURERS():
         "DYNAMIC_CWD_ELISION_CHAR": (is_string, ensure_string, ensure_string),
         "EXPAND_ENV_VARS": (is_bool, to_bool, bool_to_str),
         "FORCE_POSIX_PATHS": (is_bool, to_bool, bool_to_str),
+        "FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": (is_bool, to_bool, bool_to_str),
         "FOREIGN_ALIASES_OVERRIDE": (is_bool, to_bool, bool_to_str),
         "FUZZY_PATH_COMPLETION": (is_bool, to_bool, bool_to_str),
         "GLOB_SORTED": (is_bool, to_bool, bool_to_str),
@@ -360,6 +361,7 @@ def DEFAULT_VALUES():
         "DYNAMIC_CWD_ELISION_CHAR": "",
         "EXPAND_ENV_VARS": True,
         "FORCE_POSIX_PATHS": False,
+        "FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": False,
         "FOREIGN_ALIASES_OVERRIDE": False,
         "PROMPT_FIELDS": dict(prompt.PROMPT_FIELDS),
         "FUZZY_PATH_COMPLETION": True,
@@ -570,6 +572,12 @@ def DEFAULT_DOCS():
             "completion if set to anything truthy.",
             configurable=ON_WINDOWS,
         ),
+        "FOREIGN_ALIASES_SUPPRESS_SKIP_MESSAGE": VarDocs(
+            "Whether or not foreign aliases should suppress the message "
+            "that informs the user when a foreign alias has been skipped "
+            "because it already exists in xonsh.",
+            configurable=True,
+        ),
         "FOREIGN_ALIASES_OVERRIDE": VarDocs(
             "Whether or not foreign aliases should override xonsh aliases "
             "with the same name. Note that setting of this must happen in the "


Test patch: