From 0f6b0e5133be19b2519ca1382f728ded2006ec8b Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 22 Aug 2020 00:01:38 +0000 Subject: [PATCH] Shell cosmetic changes --- bin/credentials.sh | 12 ++++-------- bin/fetch.sh | 10 +++++----- bin/imgresize.sh | 12 ++++++++---- bin/invidious.sh | 9 ++++----- bin/plumb.sh | 14 +++++++------- bin/rfcopen.sh | 6 ++---- bin/screenshot.sh | 15 ++++++++++----- bin/sekrit.sh | 25 +++++++++++-------------- dotfiles/profile | 10 +++++++--- dotfiles/shrc | 8 +++++--- dotfiles/xinitrc | 6 +++--- 11 files changed, 66 insertions(+), 61 deletions(-) diff --git a/bin/credentials.sh b/bin/credentials.sh index 40dbd65..1eeab1b 100644 --- a/bin/credentials.sh +++ b/bin/credentials.sh @@ -85,14 +85,10 @@ pass=no user=no while getopts mpu flag; do case $flag in - m) mfa=check - ;; - p) pass=check - ;; - u) user=check - ;; - *) usage - ;; + m) mfa=check ;; + p) pass=check ;; + u) user=check ;; + *) usage ;; esac done shift $((OPTIND - 1)) diff --git a/bin/fetch.sh b/bin/fetch.sh index b65bded..52ef9ce 100644 --- a/bin/fetch.sh +++ b/bin/fetch.sh @@ -65,11 +65,11 @@ for url; do mkdir -p "$outdir" { - fetch_cmd -o "$outdir/file" "$url" \ - && printf "%s\n" "$url" >"$outdir/url" \ - && printf "%s\n" "$name" >"$outdir/name" \ - && printf "%s\n" "$url" >>"$everything" \ - && printf "%s\n" "$outdir/file" + fetch_cmd -o "$outdir/file" "$url" && + printf "%s\n" "$url" >"$outdir/url" && + printf "%s\n" "$name" >"$outdir/name" && + printf "%s\n" "$url" >>"$everything" && + printf "%s\n" "$outdir/file" } || rc=1 done exit $rc diff --git a/bin/imgresize.sh b/bin/imgresize.sh index bf3dc46..724b40a 100644 --- a/bin/imgresize.sh +++ b/bin/imgresize.sh @@ -47,9 +47,11 @@ case $infile in *.jpg | *.jpeg) inprog=jpegtopnm ;; -*.png) inprog=pngtopam +*.png) + inprog=pngtopam ;; -*) err "unknown input format" +*) + err "unknown input format" ;; esac @@ -58,9 +60,11 @@ case $outfile in *.jpg | *.jpeg) outprog=pnmtojpeg ;; -*.png) outprog=pamtopng +*.png) + outprog=pamtopng ;; -*) err "unknown output format" +*) + err "unknown output format" ;; esac diff --git a/bin/invidious.sh b/bin/invidious.sh index a738b61..dcd9a4e 100644 --- a/bin/invidious.sh +++ b/bin/invidious.sh @@ -53,7 +53,8 @@ get_id_query() id= for param; do case $param in - v=*) id=${param#v=} + v=*) + id=${param#v=} break ;; esac @@ -78,10 +79,8 @@ get_id() torsocks=torsocks while getopts T flag; do case $flag in - T) torsocks= - ;; - *) usage - ;; + T) torsocks= ;; + *) usage ;; esac done shift $((OPTIND - 1)) diff --git a/bin/plumb.sh b/bin/plumb.sh index 1e7d7a9..e3afc7f 100644 --- a/bin/plumb.sh +++ b/bin/plumb.sh @@ -12,7 +12,7 @@ usage() { - printf "Usage: %s [-T] [URI|file]\n" "${0##*/}">&2 + printf "Usage: %s [-T] [URI|file]\n" "${0##*/}" >&2 exit 1 } @@ -32,10 +32,8 @@ check_required_program fetch Tflag= while getopts T flag; do case $flag in - T) Tflag=-T - ;; - *) usage - ;; + T) Tflag=-T ;; + *) usage ;; esac done shift $((OPTIND - 1)) @@ -55,7 +53,8 @@ case $target in http://* | https://*) file=$(fetch $Tflag "$target") || err "couldn't fetch $target" ;; -*) [ -f "$target" ] || err "can't handle $uri" +*) + [ -f "$target" ] || err "can't handle $uri" file=$target ;; esac @@ -84,6 +83,7 @@ video/*) check_required_program mpv mpv "$file" ;; -*) err "don't know how to open $mimetype" +*) + err "don't know how to open $mimetype" ;; esac diff --git a/bin/rfcopen.sh b/bin/rfcopen.sh index 4ebc4ee..ccaef96 100644 --- a/bin/rfcopen.sh +++ b/bin/rfcopen.sh @@ -32,10 +32,8 @@ tonumber() torsocks=torsocks while getopts T flag; do case $flag in - T) torsocks= - ;; - *) usage - ;; + T) torsocks= ;; + *) usage ;; esac done shift $((OPTIND - 1)) diff --git a/bin/screenshot.sh b/bin/screenshot.sh index 2ae8ef1..c605a9c 100644 --- a/bin/screenshot.sh +++ b/bin/screenshot.sh @@ -29,18 +29,23 @@ err() } case $# in -0) set -- -root +0) + set -- -root ;; -1) [ "$1" = "-window" ] || err "unknown option $1" +1) + [ "$1" = "-window" ] || err "unknown option $1" set -- ;; -2) [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "unknown option $1" +2) + [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "unknown option $1" [ -n "$2" ] || err "$1 expects a non-empty parameter" ;; -*) usage +*) + usage ;; esac : ${SCREENSHOTS:=~/media/ss} -xwd -silent "$@" | xwdtopnm | +xwd -silent "$@" | + xwdtopnm | pnmtopng >"$SCREENSHOTS/$(date +%Y%m%d-%H%M%S).png" diff --git a/bin/sekrit.sh b/bin/sekrit.sh index f1960f9..680cff2 100644 --- a/bin/sekrit.sh +++ b/bin/sekrit.sh @@ -22,8 +22,8 @@ # # sekrit get account/user | xclip -r -l 1 -sel clip -q # sekrit get account/pass | xclip -r -l 1 -sel clip -q -# sekrit has account/2fa && sekrit get account/2fa \ -# | $program_for_totp | xclip -r -l 1 -sel clip -q +# sekrit has account/2fa && sekrit get account/2fa | +# $program_for_totp | xclip -r -l 1 -sel clip -q usage() { @@ -67,10 +67,8 @@ sekrit_add() OPTIND=1 while getopts f flag; do case "$flag" in - k) force=yes - ;; - *) usage - ;; + k) force=yes ;; + *) usage ;; esac done shift $((OPTIND - 1)) @@ -104,10 +102,8 @@ sekrit_cp() rmlastnl=-rmlastnl while getopts k flag; do case "$flag" in - k) rmlastnl= - ;; - *) usage - ;; + k) rmlastnl= ;; + *) usage ;; esac done shift $((OPTIND - 1)) @@ -128,8 +124,7 @@ sekrit_gen() l) len=$(to_number "$OPTARG") || err "invalid password length" ;; - *) usage - ;; + *) usage ;; esac done shift $((OPTIND - 1)) @@ -142,7 +137,8 @@ sekrit_gen() chars=$1 fi - tr -cd -- "$chars" /dev/null && + tr -cd -- "$chars" /dev/null && printf "\n" } @@ -171,7 +167,8 @@ sekrit_has() ls_key() { d=$SEKRIT_DIR$1 - find "$d" -type f -name "*.gpg" | sort | + find "$d" -type f -name "*.gpg" | + sort | sed -e "s#^$d##" -e "s#\.gpg\$##" } diff --git a/dotfiles/profile b/dotfiles/profile index c1e618f..9b97362 100644 --- a/dotfiles/profile +++ b/dotfiles/profile @@ -1,5 +1,5 @@ # env -# Written in 2019 by Lucas +# Written in 2019-2020 by Lucas # CC0 1.0 Universal/Public domain - No rights reserved # # To the extent possible under law, the author(s) have dedicated all @@ -18,8 +18,12 @@ export PATH HOME TERM LC_CTYPE case "$-" in *i*) case "$SHELL" in - /bin/bash) . ~/.shrc ;; - /bin/ksh | /bin/loksh | /bin/mksh) export ENV=~/.shrc ;; + /bin/bash) + . ~/.shrc + ;; + *) + export ENV=~/.shrc + ;; esac esac diff --git a/dotfiles/shrc b/dotfiles/shrc index 4deda1d..fd1aed2 100644 --- a/dotfiles/shrc +++ b/dotfiles/shrc @@ -1,5 +1,5 @@ # env -# Written in 2019 by Lucas +# Written in 2019-2020 by Lucas # CC0 1.0 Universal/Public domain - No rights reserved # # To the extent possible under law, the author(s) have dedicated all @@ -45,13 +45,15 @@ case $SHELL in /bin/mksh) PS1=$PS1'${HOSTNAME:=$(hostname -s)}\$ ' ;; -*) PS1=$PS1'\h\$ ' +*) + PS1=$PS1'\h\$ ' ;; esac export PS1 case $(uname -s) in -Linux) stty erase "^?" +Linux) + stty erase "^?" ;; esac diff --git a/dotfiles/xinitrc b/dotfiles/xinitrc index b879acf..1336f11 100755 --- a/dotfiles/xinitrc +++ b/dotfiles/xinitrc @@ -19,9 +19,9 @@ setxkbmap \ xset r rate 300 75 xset b off -test -d /usr/local/share/fonts/bitmaps \ - && xset +fp /usr/local/share/fonts/bitmaps \ - && xset fp rehash +test -d /usr/local/share/fonts/bitmaps && + xset +fp /usr/local/share/fonts/bitmaps && + xset fp rehash test -r ~/.Xresources && xrdb -merge ~/.Xresources exec herbstluftwm -l >~/local/var/log/herbstluftwm 2>&1