env: add XONSH_SUPPRESS_WELCOME to suppress welcome msg (#5719)

add `XONSH_SUPPRESS_WELCOME` variable to suppress welcome msg

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
This commit is contained in:
Jueun Lee 2024-11-19 08:04:24 +09:00 committed by GitHub
parent 6fefc3c68d
commit 599f1c0f36
Failed to generate hash of commit
3 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* env: Added ``$XONSH_SUPPRESS_WELCOME`` variable to suppress the welcome message.
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -1627,6 +1627,10 @@ class PromptSetting(Xettings):
"For example, to have stderr appear on a red background, the " "For example, to have stderr appear on a red background, the "
'prefix & postfix pair would be "{BACKGROUND_RED}" & "{RESET}".', 'prefix & postfix pair would be "{BACKGROUND_RED}" & "{RESET}".',
) )
XONSH_SUPPRESS_WELCOME = Var.with_default(
False,
"Suppresses the welcome message.",
)
class PromptHistorySetting(Xettings): class PromptHistorySetting(Xettings):

View file

@ -548,6 +548,7 @@ def main_xonsh(args):
ignore_sigtstp() ignore_sigtstp()
if ( if (
env["XONSH_INTERACTIVE"] env["XONSH_INTERACTIVE"]
and not env["XONSH_SUPPRESS_WELCOME"]
and sys.stdin.isatty() # In case the interactive mode is forced but no tty (input from pipe). and sys.stdin.isatty() # In case the interactive mode is forced but no tty (input from pipe).
and not any(os.path.isfile(i) for i in env["XONSHRC"]) and not any(os.path.isfile(i) for i in env["XONSHRC"])
and not any(os.path.isdir(i) for i in env["XONSHRC_DIR"]) and not any(os.path.isdir(i) for i in env["XONSHRC_DIR"])