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:
parent
b9382832ad
commit
124acb089c
1 changed files with 7 additions and 1 deletions
|
@ -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