1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-17 16:49:45 +01:00

home-manager: colorize only when connected to terminal

Before, the output of `home-manager generations` would be colorized
even when used in a pipeline.

(cherry picked from commit 06e7d087f2)
This commit is contained in:
Robert Helgesson 2018-03-03 21:58:22 +01:00
parent b9382832ad
commit 124acb089c
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86

View file

@ -159,9 +159,15 @@ function doSwitch() {
}
function doListGens() {
# Whether to colorize the generations output.
local color="never"
if [[ -t 1 ]]; then
color="always"
fi
pushd "/nix/var/nix/profiles/per-user/$USER" > /dev/null
# shellcheck disable=2012
ls --color=yes -gG --time-style=long-iso --sort time home-manager-*-link \
ls --color=$color -gG --time-style=long-iso --sort time home-manager-*-link \
| cut -d' ' -f 4- \
| sed -E 's/home-manager-([[:digit:]]*)-link/: id \1/'
popd > /dev/null