diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-06 18:28:15 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-06 18:28:15 +1200 |
commit | a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2 (patch) | |
tree | 07637d82dbf4e8918e7f919492a3173d8effed8e /sh/shrc.d | |
parent | Fix a README error (diff) | |
download | dotfiles-a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2.tar.gz dotfiles-a567d165b8fe8f03ee6bcfad3dea06cdb5f3e2a2.zip |
Make -x in ls() conditional on terminal output
Mimics behaviour of GNU ls(1) and probably other implementations too
Diffstat (limited to 'sh/shrc.d')
-rw-r--r-- | sh/shrc.d/ls.sh | 6 |
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 ] && |