From a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 6 Apr 2017 18:28:15 +1200 Subject: Make -x in ls() conditional on terminal output Mimics behaviour of GNU ls(1) and probably other implementations too --- sh/shrc.d/ls.sh | 6 ++++-- 1 file 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 ] && -- cgit v1.2.3