Merge pull request #3688 from laloch/env-hostname

Add $HOSTNAME and $HOSTTYPE environment variables
This commit is contained in:
Anthony Scopatz 2020-08-16 01:56:39 -05:00 committed by GitHub
commit 1df65ee369
Failed to generate hash of commit
2 changed files with 38 additions and 1 deletions

23
news/env-hostname.rst Normal file
View file

@ -0,0 +1,23 @@
**Added:**
* Added ``$HOSTNAME`` and ``$HOSTTYPE`` environment variables.
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -12,6 +12,7 @@ import contextlib
import collections
import collections.abc as cabc
import subprocess
import platform
from xonsh import __version__ as XONSH_VERSION
from xonsh.lazyasd import LazyObject, lazyobject
@ -87,7 +88,6 @@ from xonsh.ansi_colors import (
)
import xonsh.prompt.base as prompt
events.doc(
"on_envvar_new",
"""
@ -942,6 +942,20 @@ def DEFAULT_VARS():
"Note: ``erasedups`` is supported only in sqlite backend).",
doc_store_as_str=True,
),
"HOSTNAME": Var(
is_string,
ensure_string,
ensure_string,
default_value(lambda env: platform.node()),
"Automatically set to the name of the current host.",
),
"HOSTTYPE": Var(
is_string,
ensure_string,
ensure_string,
default_value(lambda env: platform.machine()),
"Automatically set to a string that fully describes the system type on which xonsh is executing.",
),
"IGNOREEOF": Var(
is_bool,
to_bool,