aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-24 11:51:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-24 11:51:47 +1200
commit21f62c8c2af0db01094b73faf77065ba39abad8a (patch)
treee14af1f7f85112affaa0dedde85011c5fd0268d0
parentRename gress() to gore() (diff)
downloaddotfiles-21f62c8c2af0db01094b73faf77065ba39abad8a.tar.gz
dotfiles-21f62c8c2af0db01094b73faf77065ba39abad8a.zip
Force --hide-control-chars on ls(1) if available
I prefer it to literal or C-style escaping representations, and ls(1) isn't for scripting output anyway.
-rw-r--r--sh/profile.d/options.sh11
-rw-r--r--sh/shrc.d/ls.sh6
2 files changed, 12 insertions, 5 deletions
diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh
index aa6bea06..d4dc45a3 100644
--- a/sh/profile.d/options.sh
+++ b/sh/profile.d/options.sh
@@ -46,10 +46,11 @@ options grep \
# Cache options for ls(1)
options ls \
- almost-all \
- block-size \
- classify \
- color \
- human-readable \
+ almost-all \
+ block-size \
+ classify \
+ color \
+ hide-control-chars \
+ human-readable \
time-style
)
diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh
index 8fd42431..705936e6 100644
--- a/sh/shrc.d/ls.sh
+++ b/sh/shrc.d/ls.sh
@@ -18,6 +18,12 @@ ls() {
[ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] &&
set -- --color=auto "$@"
+ # Add --hide-control-chars if present; we always want this interactively,
+ # even if the output is to a pager; we shouldn't be trying to script ls(1)
+ # output anyway
+ [ -e "$HOME"/.cache/ls/hide-control-chars ] &&
+ set -- --hide-control-chars "$@"
+
# Add --time-style='+%Y-%m-%d %H:%M:%S' to show trailing indicators of the
# filetype
[ -e "$HOME"/.cache/ls/time-style ] &&