aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-04-06 18:28:15 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-04-06 18:28:15 +1200
commita567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2 (patch)
tree07637d82dbf4e8918e7f919492a3173d8effed8e /sh
parent80b9f391473843ec290c37a6468be1810c1b5076 (diff)
downloaddotfiles-a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2.tar.gz
Make -x in ls() conditional on terminal output
Mimics behaviour of GNU ls(1) and probably other implementations too
Diffstat (limited to 'sh')
-rw-r--r--sh/shrc.d/ls.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh
index 58263e96..18f50a8b 100644
--- a/sh/shrc.d/ls.sh
+++ b/sh/shrc.d/ls.sh
@@ -14,8 +14,10 @@ ls() {
# -F to show trailing indicators of the filetype
# -q to replace control chars with '?'
- # -x to format entries across, not down
- set -- -Fqx "$@"
+ set -- -Fq "$@"
+
+ # If output is to a terminal, add -x to format entries across, not down
+ [ -t 1 ] && set -- -x "$@"
# Add --block-size=K to always show the filesize in kibibytes
[ -e "$HOME"/.cache/ls/block-size ] &&