aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-11 16:29:04 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-11 16:29:04 +1300
commitd3f446c9508be8fc0fde70981918b1d000e37ae0 (patch)
tree4de70504a8640c03d68a02b9ecd9f57f7c805931
parentAdd an idea (diff)
downloaddotfiles-d3f446c9508be8fc0fde70981918b1d000e37ae0.tar.gz
dotfiles-d3f446c9508be8fc0fde70981918b1d000e37ae0.zip
Use POSIX-compatible versions of ls(1) opts
-rw-r--r--IDEAS.markdown2
-rw-r--r--sh/profile.d/options.sh11
-rw-r--r--sh/shrc.d/ls.sh25
3 files changed, 14 insertions, 24 deletions
diff --git a/IDEAS.markdown b/IDEAS.markdown
index 145efb28..f7e3341b 100644
--- a/IDEAS.markdown
+++ b/IDEAS.markdown
@@ -9,5 +9,3 @@ Ideas
* Have eds(1df) accept stdin with the "starting content" for the script
* Convert all the manual pages to mandoc maybe? <https://en.wikipedia.org/wiki/Mandoc>
* Add "pop" and "shift" methods to path()
-* `ls()` function flags can probably be made more generic by looking for
- their short POSIX equivalents if any
diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh
index aa7e9ace..345888d0 100644
--- a/sh/profile.d/options.sh
+++ b/sh/profile.d/options.sh
@@ -46,12 +46,9 @@ options grep \
# Cache options for ls(1)
options ls \
- almost-all \
- block-size \
- classify \
- color \
- format \
- hide-control-chars \
- human-readable \
+ almost-all \
+ block-size \
+ color \
+ human-readable \
time-style
)
diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh
index 7e916239..40da567a 100644
--- a/sh/shrc.d/ls.sh
+++ b/sh/shrc.d/ls.sh
@@ -5,31 +5,26 @@
# Define function proper
ls() {
+ # Add -F to show trailing indicators of the filetype
+ set -- -F "$@"
+
+ # Add -q to replace control chars with '?'
+ set -- -q "$@"
+
+ # Format with entries sorted across, not down, in columns
+ set -- -x "$@"
+
# Add --block-size=K to always show the filesize in kibibytes
[ -e "$HOME"/.cache/ls/block-size ] &&
set -- --block-size=1024 "$@"
- # Add --classify to show trailing indicators of the filetype
- [ -e "$HOME"/.cache/ls/classify ] &&
- set -- --classify "$@"
-
# Add --color if the terminal has at least 8 colors
[ -e "$HOME"/.cache/ls/color ] &&
[ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] &&
set -- --color=auto "$@"
- # Add --format=horizontal to print entries in a saner way
- [ -e "$HOME"/.cache/ls/format ] &&
- set -- --format=horizontal "$@"
-
- # 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 the date in my preferred
- # format
+ # (fixed) format
[ -e "$HOME"/.cache/ls/time-style ] &&
set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@"