aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/tree.sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-26 13:48:38 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-26 13:48:38 +1200
commit9820de29e08156b39b0f3afcc59c0e8f2f544b2b (patch)
tree1ae3ef2a38a9a1d7fdc3496d2cc21ed22debdf1f /sh/shrc.d/tree.sh
parentAdd subsection for dotfiles(7df) (diff)
downloaddotfiles-9820de29e08156b39b0f3afcc59c0e8f2f544b2b.tar.gz
dotfiles-9820de29e08156b39b0f3afcc59c0e8f2f544b2b.zip
Add tree()
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 "$@"
+}