diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-14 13:14:00 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-12-14 13:14:00 +1300 |
commit | e0ff7ac01d6439d826ff9ef6f134a7638ade714f (patch) | |
tree | 781004065fefcbfd8e543a61de3d168383e71bde /sh/shrc.d/ls.sh | |
parent | Merge branch 'release/v3.1.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-e0ff7ac01d6439d826ff9ef6f134a7638ade714f.tar.gz dotfiles-e0ff7ac01d6439d826ff9ef6f134a7638ade714f.zip |
Merge branch 'release/v3.2.0'v3.2.0
* release/v3.2.0:
Bump VERSION
Refactor some conditionals
Factor out zsh ENV hack into one file
Refactor "path list" not to require a subshell
Correct completion for deep pass(1) directories
Move filetype.vim helper funcs into autoload
Fix a local var name in openssl(1ssl) completion
Correct a variable ref in openssl(1ssl) completion
Disable shellcheck rules for missed definition
Add filenames treatment to mex(1df) completion
Remove unneeded declaration
Refactor some completions to avoid loops
Remove unneeded stdout redirect
Remove unneeded semicolon from sh "for VAR ; do"
Substitute bad `continue` for `return`
Add actual completion matching to git completion
Apply much simpler completion to Git
Diffstat (limited to 'sh/shrc.d/ls.sh')
-rw-r--r-- | sh/shrc.d/ls.sh | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh index 7e843cc7..1083dfca 100644 --- a/sh/shrc.d/ls.sh +++ b/sh/shrc.d/ls.sh @@ -12,26 +12,30 @@ unset -v LS_OPTIONS LS_COLORS # Define function proper ls() { - # -F to show trailing indicators of the filetype - # -q to replace control chars with '?' + # POSIX options: + ## -F to show trailing indicators of the filetype + ## -q to replace control chars with '?' 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/sh/opt/ls/block-size ] && + ## -x to format entries across, not down, if output looks like a terminal + if [ -t 1 ] ; then + set -- -x "$@" + fi + + # GNU options: + ## Add --block-size=K to always show the filesize in kibibytes + if [ -e "$HOME"/.cache/sh/opt/ls/block-size ] ; then set -- --block-size=1024 "$@" - - # Add --color if the terminal has at least 8 colors - [ -e "$HOME"/.cache/sh/opt/ls/color ] && - [ "$({ tput colors||tput Co||echo 0; } 2>/dev/null)" -ge 8 ] && + fi + ## Add --color if the terminal has at least 8 colors + if [ -e "$HOME"/.cache/sh/opt/ls/color ] && + [ "$(exec 2>/dev/null;tput colors||tput Co||echo 0)" -ge 8 ] ; then set -- --color=auto "$@" - - # Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred - # (fixed) format - [ -e "$HOME"/.cache/sh/opt/ls/time-style ] && + fi + ## Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred + ## (fixed) format + if [ -e "$HOME"/.cache/sh/opt/ls/time-style ] ; then set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@" + fi # If the operating system is FreeBSD, there are some specific options we # can add that might mean different things to e.g. GNU ls(1) |