From 3f4c9aeca759812e09d10c17adb43ea30e4036da Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 28 Apr 2021 15:03:25 +0200 Subject: Read colorization from environment variable, if command line is not set (#23130) --- lib/spack/docs/basic_usage.rst | 8 +++++++- lib/spack/spack/main.py | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/docs/basic_usage.rst b/lib/spack/docs/basic_usage.rst index a8a45b65cb..db69ba42e9 100644 --- a/lib/spack/docs/basic_usage.rst +++ b/lib/spack/docs/basic_usage.rst @@ -27,12 +27,18 @@ It is recommended that the following be put in your ``.bashrc`` file: If you do not see colorized output when using ``less -R`` it is because color is being disabled in the piped output. In this case, tell spack to force -colorized output. +colorized output with a flag .. code-block:: console $ spack --color always | less -R +or an environment variable + +.. code-block:: console + + $ SPACK_COLOR=always spack | less -R + -------------------------- Listing available packages -------------------------- diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index be07aa3e5c..ecaf6d02f0 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -354,7 +354,8 @@ def make_argument_parser(**kwargs): dest='help', action='store_const', const='long', default=None, help="show help for all commands (same as spack help --all)") parser.add_argument( - '--color', action='store', default='auto', + '--color', action='store', + default=os.environ.get('SPACK_COLOR', 'auto'), choices=('always', 'never', 'auto'), help="when to colorize output (default: auto)") parser.add_argument( -- cgit v1.2.3-70-g09d2