bin: adjust to ubuntu sh

This commit is contained in:
xeruf 2021-11-02 11:59:08 +00:00
parent a2f4f2cd4d
commit e1ee8dba79
4 changed files with 6 additions and 6 deletions

View File

@ -2,5 +2,6 @@
{ {
echo "$# Args: $@" echo "$# Args: $@"
echo "${@:-default}" | sed 's/\w\+/\0-w/g' 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) } | tee /tmp/args$(date +%s)

View File

@ -17,7 +17,7 @@ tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$'
case "$($elevate file --dereference --mime "$last")" in 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;; *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 "$@";; *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" tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
;; ;;
esac esac

View File

@ -1,13 +1,12 @@
#!/bin/sh #!/bin/sh
# open info-page, man-page or command help # open info-page, man-page or command help
set -o pipefail
paginate="${PAGER:-less} +Gg" paginate="${PAGER:-less} +Gg"
test "$1" = "-d" && browse=1 && shift test "$1" = "-d" && browse=1 && shift
case $1 in case $1 in
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages (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 # 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;; (vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
(gh|chordpro) $@ --help | $paginate;; (gh|chordpro) $@ --help | $paginate;;
(caddy) $1 help ${@:2} | $paginate;; (caddy) $1 help ${@:2} | $paginate;;

View File

@ -2,7 +2,7 @@
# Creates the last arg as directory (or its parent if not ending in a slash) # Creates the last arg as directory (or its parent if not ending in a slash)
# and moves the preceding arguments into it. # and moves the preceding arguments into it.
# Automatically elevates if missing permissions. # Automatically elevates if missing permissions.
last=${@:$#} for last; do true; done
! test -e "$1" && echo "$1 does not exist" && exit 1 ! test -e "$1" && echo "$1 does not exist" && exit 1
checkaccess -w "$@" || elevate=sudo checkaccess -w "$@" || elevate=sudo
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)