aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/tree.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/shrc.d/tree.sh')
-rw-r--r--sh/shrc.d/tree.sh9
1 files changed, 9 insertions, 0 deletions
diff --git a/sh/shrc.d/tree.sh b/sh/shrc.d/tree.sh
new file mode 100644
index 00000000..5feb8ca3
--- /dev/null
+++ b/sh/shrc.d/tree.sh
@@ -0,0 +1,9 @@
+# I don't like the LS_COLORS environment variable, but GNU tree(1) doesn't
+# color its output by default without it; this will coax it into doing so with
+# the default colors when writing to a terminal.
+tree() {
+ [ -t 1 ] &&
+ [ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] &&
+ set -- -C "$@"
+ command "$@"
+}