From e1ee8dba798803cf58abfe8c6f8a2f3b2ef408d1 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 2 Nov 2021 11:59:08 +0000 Subject: [PATCH] bin: adjust to ubuntu sh --- .local/bin/scripts/arg-test | 3 ++- .local/bin/scripts/b | 2 +- .local/bin/scripts/help | 5 ++--- .local/bin/scripts/m | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.local/bin/scripts/arg-test b/.local/bin/scripts/arg-test index 8a20d9a..2328384 100755 --- a/.local/bin/scripts/arg-test +++ b/.local/bin/scripts/arg-test @@ -2,5 +2,6 @@ { echo "$# Args: $@" echo "${@:-default}" | sed 's/\w\+/\0-w/g' -#echo "Last arg: ${@:$#}" +for last; do true; done +echo "Last arg: $last" } | tee /tmp/args$(date +%s) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 8e71958..ab413f3 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -17,7 +17,7 @@ tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$' case "$($elevate file --dereference --mime "$last")" in *inode/directory*) tput sgr0 && $(test -x "$last" || echo "sudo") ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@" | less -XF;; *binary) expr "$(file "$last")" : ".*: .*compress" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";; - *) $elevate bat --style header "$@" "$(test -n "$elevate" || echo "--pager=less -XF")" + *) $elevate bat --style header "$@" --pager 'less -RXF' tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last" ;; esac diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index ed32d3f..6da17e4 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -1,13 +1,12 @@ #!/bin/sh # open info-page, man-page or command help -set -o pipefail paginate="${PAGER:-less} +Gg" test "$1" = "-d" && browse=1 && shift case $1 in (zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages - search="${@:$#}" + for last; do true; done # need to install zsh-doc package for info pages - info --vi-keys $(test $search != zsh && echo --index-search=$search) zsh || LESS="$LESS +/^ *${@:$#} *\\[" man zshall;; + info --vi-keys $(test $last != zsh && echo --index-search=$last) zsh || LESS="$LESS +/^ *$last *\\[" man zshall;; (vlc) unbuffer vlc --full-help "${@:2}" | $paginate;; (gh|chordpro) $@ --help | $paginate;; (caddy) $1 help ${@:2} | $paginate;; diff --git a/.local/bin/scripts/m b/.local/bin/scripts/m index b039df2..931fff1 100755 --- a/.local/bin/scripts/m +++ b/.local/bin/scripts/m @@ -2,7 +2,7 @@ # Creates the last arg as directory (or its parent if not ending in a slash) # and moves the preceding arguments into it. # Automatically elevates if missing permissions. -last=${@:$#} +for last; do true; done ! test -e "$1" && echo "$1 does not exist" && exit 1 checkaccess -w "$@" || elevate=sudo $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)