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:
parent
b9382832ad
commit
124acb089c
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue