bin: little script fixes
This commit is contained in:
parent
6610e4edba
commit
e8eeb04303
|
@ -9,7 +9,7 @@ if test "$1" = "f"
|
||||||
lsblk --output name,size,fsavail,fsuse%,mountpoint$outcols,label,fstype$(test "${cols:-0}" -gt 120 && echo ',uuid') $width $cols |
|
lsblk --output name,size,fsavail,fsuse%,mountpoint$outcols,label,fstype$(test "${cols:-0}" -gt 120 && echo ',uuid') $width $cols |
|
||||||
while read line
|
while read line
|
||||||
do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0')
|
do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0')
|
||||||
printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\n" "$line"
|
printf "$(expr "$line" : " " >/dev/null || echo "\033[$(test -z "$first" && echo "4" || expr "5;31" \& "$p" \> 98 \| "31" \& "$p" \> 97 \| "33" \& "$p" \> 94 \| "35" \& "$p" \> 90)m")%s\033[39m\n" "$line"
|
||||||
first=1
|
first=1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
# optdepends: highlight(dotfiles)
|
# optdepends: highlight(dotfiles)
|
||||||
paginate="${PAGER:-less} +Gg"
|
paginate="${PAGER:-less} +Gg"
|
||||||
test "$1" = "-d" && browse=1 && shift
|
test "$1" = "-d" && browse=1 && shift
|
||||||
# TODO resolve aliases
|
# TODO resolve aliases in 'h' alias
|
||||||
|
# TODO call 'wh' on scripts instead
|
||||||
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
|
||||||
for last; do true; done
|
for last; do true; done
|
||||||
|
@ -16,12 +17,14 @@ case $1 in
|
||||||
(plantuml) unbuffer "$@" -help | $paginate;;
|
(plantuml) unbuffer "$@" -help | $paginate;;
|
||||||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||||
(kdeconnect*) kdeconnect-cli --help-all "${@:2}" | $paginate;;
|
(kdeconnect*) kdeconnect-cli --help-all "${@:2}" | $paginate;;
|
||||||
(pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions;;
|
(pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions | paste -s -d' ';;
|
||||||
(swaymsg) test $# -gt 1 && man sway "${@:2}" || man swaymsg;;
|
(swaymsg) test $# -gt 1 && man sway "${@:2}" || man swaymsg;;
|
||||||
(swaymsg-*) man sway "${1#swaymsg-}";;
|
(swaymsg-*) man sway "${1#swaymsg-}";;
|
||||||
(*) man "$@" ||
|
(*) man "$@" ||
|
||||||
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
|
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
|
||||||
if which "$1" >/dev/null; then "$@" --help; "$@" -help; "$@" -h 2>&1 | $paginate; fi;;
|
if which "$1" >/dev/null
|
||||||
|
then "$@" --help || echo $? == 1 && "$@" -help || echo $? == 1 && "$@" -h 2>&1 | $paginate
|
||||||
|
fi;;
|
||||||
esac
|
esac
|
||||||
docs="/usr/share/doc/$1"
|
docs="/usr/share/doc/$1"
|
||||||
if test -d "$docs"; then
|
if test -d "$docs"; then
|
||||||
|
|
|
@ -12,7 +12,7 @@ do
|
||||||
test "$answer" = "y" &&
|
test "$answer" = "y" &&
|
||||||
$elevate rm -rf "$f"
|
$elevate rm -rf "$f"
|
||||||
else
|
else
|
||||||
$elevate find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
$elevate find "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 4) -type d -o -type f -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
||||||
test $# -eq 0 && exit $?
|
test $# -eq 0 && exit $?
|
||||||
if test -e "$f"; then
|
if test -e "$f"; then
|
||||||
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
|
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh -e
|
||||||
# Lossy image compression using ImageMagick
|
# Lossy image compression using ImageMagick
|
||||||
# Tries to eliminate artifacts
|
# Eliminates artifacts and metadata
|
||||||
while true
|
while true
|
||||||
do case $1 in
|
do case $1 in
|
||||||
|
(-h|--help|"") echo "Usage: $0 [-q quality (default 85)] [-o outfile] [xRES] <images...>" && exit 2;;
|
||||||
(-o) out="$2"; shift 2;;
|
(-o) out="$2"; shift 2;;
|
||||||
(-q) quality="$2"; shift 2;;
|
(-q) quality="$2"; shift 2;;
|
||||||
|
(x*) resolution="$1"; resize="-resize $resolution"; shift;;
|
||||||
(*) break;;
|
(*) break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
out="${out:-$1-shrinked.jpg}"
|
out="${out:-$1${resolution:--shrinked}.jpg}"
|
||||||
test $# -eq 0 && echo "Usage: $0 [-q quality (default 85)] [-o outfile] <images...>" && exit 1
|
magick "$@" -auto-orient -strip \
|
||||||
magick "$@" -auto-orient -strip -interlace Plane -define jpeg:dct-method=float -sampling-factor 4:2:0 -gaussian-blur 0.05 \
|
-interlace Plane -define jpeg:dct-method=float -sampling-factor 4:2:0 -gaussian-blur 0.05 \
|
||||||
-quality "${quality:-85}" "$out"
|
-quality "${quality:-85}" $resize "$out"
|
||||||
printf "Shrinked $1(%s) to $out(%s) - reduced to %s%%\n" \
|
printf "Shrinked $1(%s) to $out(%s) - reduced to %s%%\n" \
|
||||||
$(stat --format %s "$1" "$out" | numfmt --to=iec-i --suffix=B) \
|
$(stat --format %s "$1" "$out" | numfmt --to=iec-i --suffix=B) \
|
||||||
$(stat --format %s "$out" "$1" | sed 'N;s|\n|*100/|' | bc)
|
$(stat --format %s "$out" "$1" | sed 'N;s|\n|*100/|' | bc)
|
||||||
|
|
|
@ -6,7 +6,7 @@ print("\\033[XXm")
|
||||||
for i in range(30,37+1):
|
for i in range(30,37+1):
|
||||||
print("\033[%dm%d\t\t\033[%dm%d" % (i,i,i+60,i+60));
|
print("\033[%dm%d\t\t\033[%dm%d" % (i,i,i+60,i+60));
|
||||||
|
|
||||||
print("\033[39m\\033[49m - Reset colour")
|
print("\033[39m\\033[39m - Reset colour (0 to reset all)")
|
||||||
print("\\033[2K - Clear Line")
|
print("\\033[2K - Clear Line")
|
||||||
print("\\033[<L>;<C>H OR \\033[<L>;<C>f puts the cursor at line L and column C.")
|
print("\\033[<L>;<C>H OR \\033[<L>;<C>f puts the cursor at line L and column C.")
|
||||||
print("\\033[<N>A Move the cursor up N lines")
|
print("\\033[<N>A Move the cursor up N lines")
|
||||||
|
|
Loading…
Reference in New Issue