diff options
author | Seth House <seth@eseth.com> | 2023-08-11 11:35:41 -0600 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2023-08-13 23:19:44 +0200 |
commit | 8c9e94a8b6e9fb0aad16baa21a5ab8d1e2719151 (patch) | |
tree | 42c973f50bd6e669ce930d33070f5f42218f7283 | |
parent | 64e90e76acb4d6575273c57eaa02c9b4f2665b91 (diff) | |
download | lr-8c9e94a8b6e9fb0aad16baa21a5ab8d1e2719151.tar.gz lr-8c9e94a8b6e9fb0aad16baa21a5ab8d1e2719151.tar.xz lr-8c9e94a8b6e9fb0aad16baa21a5ab8d1e2719151.zip |
Check lrls wrapper for a couple edge-cases
Changes: - Remove `-A` so end-users can optionally pass that in. - Avoid depth checking when it can produce ambiguous output. - Avoid path stripping when it can produce ambiguous output. - Only columnate when output is to a terminal. Closes: #25 [via git-merge-pr]
-rwxr-xr-x | contrib/lrls | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/contrib/lrls b/contrib/lrls index fc4b149..2d41447 100755 --- a/contrib/lrls +++ b/contrib/lrls @@ -1,8 +1,50 @@ #!/bin/sh # lrls - lr with GNU ls style output +# +# Usage (Bash, Zsh): +# +# # Clear any system-level aliases: +# unalias ls la ll 2>/dev/null +# alias ls='lslr -A' +# alias la='lslr' +# alias ll='lslr -lh' -color= -[ -t 1 ] && color=-GG +use_strip=1 +check_depth=1 -lr $color -A1s -t '!type == d || depth > 0' "$@" |git column --mode=dense --pad=2 +if [ -t 1 ]; then + use_color=1 + use_column=1 +fi +while getopts :01ABC:DFGHLQPST:UWXde:f:lho:st:x opt; do + case $opt in + # If we're not entering directories: + # - Avoid depth check so directory names aren't skipped entirely. + # - Avoid strip so directory names aren't replaced with dots. + d) unset check_depth + unset use_strip + ;; + # Avoid git column for long lr output. + l) unset use_column + ;; + esac +done + +# If more than one path is given as an arg, strip can produce ambiguous output +# for multi-segment paths (and has no effect on single-segment paths). +if [ "$#" -gt "$OPTIND" ]; then + unset use_strip +fi + +lr -1 \ + ${use_color:+-GG} \ + ${use_strip:+-s} \ + ${check_depth:+-t '!type == d || depth > 0'} \ + "$@" | { + if [ -n "$use_column" ]; then + git column --mode=dense --pad=2 + else + cat + fi; + } |