Shell cosmetic changes

This commit is contained in:
Lucas 2020-08-22 00:01:38 +00:00
parent a444cdcbfd
commit 0f6b0e5133
11 changed files with 66 additions and 61 deletions

View File

@ -85,14 +85,10 @@ pass=no
user=no user=no
while getopts mpu flag; do while getopts mpu flag; do
case $flag in case $flag in
m) mfa=check m) mfa=check ;;
;; p) pass=check ;;
p) pass=check u) user=check ;;
;; *) usage ;;
u) user=check
;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -65,11 +65,11 @@ for url; do
mkdir -p "$outdir" mkdir -p "$outdir"
{ {
fetch_cmd -o "$outdir/file" "$url" \ fetch_cmd -o "$outdir/file" "$url" &&
&& printf "%s\n" "$url" >"$outdir/url" \ printf "%s\n" "$url" >"$outdir/url" &&
&& printf "%s\n" "$name" >"$outdir/name" \ printf "%s\n" "$name" >"$outdir/name" &&
&& printf "%s\n" "$url" >>"$everything" \ printf "%s\n" "$url" >>"$everything" &&
&& printf "%s\n" "$outdir/file" printf "%s\n" "$outdir/file"
} || rc=1 } || rc=1
done done
exit $rc exit $rc

View File

@ -47,9 +47,11 @@ case $infile in
*.jpg | *.jpeg) *.jpg | *.jpeg)
inprog=jpegtopnm inprog=jpegtopnm
;; ;;
*.png) inprog=pngtopam *.png)
inprog=pngtopam
;; ;;
*) err "unknown input format" *)
err "unknown input format"
;; ;;
esac esac
@ -58,9 +60,11 @@ case $outfile in
*.jpg | *.jpeg) *.jpg | *.jpeg)
outprog=pnmtojpeg outprog=pnmtojpeg
;; ;;
*.png) outprog=pamtopng *.png)
outprog=pamtopng
;; ;;
*) err "unknown output format" *)
err "unknown output format"
;; ;;
esac esac

View File

@ -53,7 +53,8 @@ get_id_query()
id= id=
for param; do for param; do
case $param in case $param in
v=*) id=${param#v=} v=*)
id=${param#v=}
break break
;; ;;
esac esac
@ -78,10 +79,8 @@ get_id()
torsocks=torsocks torsocks=torsocks
while getopts T flag; do while getopts T flag; do
case $flag in case $flag in
T) torsocks= T) torsocks= ;;
;; *) usage ;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -12,7 +12,7 @@
usage() usage()
{ {
printf "Usage: %s [-T] [URI|file]\n" "${0##*/}">&2 printf "Usage: %s [-T] [URI|file]\n" "${0##*/}" >&2
exit 1 exit 1
} }
@ -32,10 +32,8 @@ check_required_program fetch
Tflag= Tflag=
while getopts T flag; do while getopts T flag; do
case $flag in case $flag in
T) Tflag=-T T) Tflag=-T ;;
;; *) usage ;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -55,7 +53,8 @@ case $target in
http://* | https://*) http://* | https://*)
file=$(fetch $Tflag "$target") || err "couldn't fetch $target" 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 file=$target
;; ;;
esac esac
@ -84,6 +83,7 @@ video/*)
check_required_program mpv check_required_program mpv
mpv "$file" mpv "$file"
;; ;;
*) err "don't know how to open $mimetype" *)
err "don't know how to open $mimetype"
;; ;;
esac esac

View File

@ -32,10 +32,8 @@ tonumber()
torsocks=torsocks torsocks=torsocks
while getopts T flag; do while getopts T flag; do
case $flag in case $flag in
T) torsocks= T) torsocks= ;;
;; *) usage ;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))

View File

@ -29,18 +29,23 @@ err()
} }
case $# in case $# in
0) set -- -root 0)
set -- -root
;; ;;
1) [ "$1" = "-window" ] || err "unknown option $1" 1)
[ "$1" = "-window" ] || err "unknown option $1"
set -- 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" [ -n "$2" ] || err "$1 expects a non-empty parameter"
;; ;;
*) usage *)
usage
;; ;;
esac esac
: ${SCREENSHOTS:=~/media/ss} : ${SCREENSHOTS:=~/media/ss}
xwd -silent "$@" | xwdtopnm | xwd -silent "$@" |
xwdtopnm |
pnmtopng >"$SCREENSHOTS/$(date +%Y%m%d-%H%M%S).png" pnmtopng >"$SCREENSHOTS/$(date +%Y%m%d-%H%M%S).png"

View File

@ -22,8 +22,8 @@
# #
# sekrit get account/user | xclip -r -l 1 -sel clip -q # sekrit get account/user | xclip -r -l 1 -sel clip -q
# sekrit get account/pass | 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 \ # sekrit has account/2fa && sekrit get account/2fa |
# | $program_for_totp | xclip -r -l 1 -sel clip -q # $program_for_totp | xclip -r -l 1 -sel clip -q
usage() usage()
{ {
@ -67,10 +67,8 @@ sekrit_add()
OPTIND=1 OPTIND=1
while getopts f flag; do while getopts f flag; do
case "$flag" in case "$flag" in
k) force=yes k) force=yes ;;
;; *) usage ;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -104,10 +102,8 @@ sekrit_cp()
rmlastnl=-rmlastnl rmlastnl=-rmlastnl
while getopts k flag; do while getopts k flag; do
case "$flag" in case "$flag" in
k) rmlastnl= k) rmlastnl= ;;
;; *) usage ;;
*) usage
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -128,8 +124,7 @@ sekrit_gen()
l) len=$(to_number "$OPTARG") || l) len=$(to_number "$OPTARG") ||
err "invalid password length" err "invalid password length"
;; ;;
*) usage *) usage ;;
;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -142,7 +137,8 @@ sekrit_gen()
chars=$1 chars=$1
fi fi
tr -cd -- "$chars" </dev/urandom | dd bs=1 count="$len" 2>/dev/null && tr -cd -- "$chars" </dev/urandom |
dd bs=1 count="$len" 2>/dev/null &&
printf "\n" printf "\n"
} }
@ -171,7 +167,8 @@ sekrit_has()
ls_key() ls_key()
{ {
d=$SEKRIT_DIR$1 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\$##" sed -e "s#^$d##" -e "s#\.gpg\$##"
} }

View File

@ -1,5 +1,5 @@
# env # env
# Written in 2019 by Lucas # Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved # CC0 1.0 Universal/Public domain - No rights reserved
# #
# To the extent possible under law, the author(s) have dedicated all # To the extent possible under law, the author(s) have dedicated all
@ -18,8 +18,12 @@ export PATH HOME TERM LC_CTYPE
case "$-" in case "$-" in
*i*) *i*)
case "$SHELL" in case "$SHELL" in
/bin/bash) . ~/.shrc ;; /bin/bash)
/bin/ksh | /bin/loksh | /bin/mksh) export ENV=~/.shrc ;; . ~/.shrc
;;
*)
export ENV=~/.shrc
;;
esac esac
esac esac

View File

@ -1,5 +1,5 @@
# env # env
# Written in 2019 by Lucas # Written in 2019-2020 by Lucas
# CC0 1.0 Universal/Public domain - No rights reserved # CC0 1.0 Universal/Public domain - No rights reserved
# #
# To the extent possible under law, the author(s) have dedicated all # To the extent possible under law, the author(s) have dedicated all
@ -45,13 +45,15 @@ case $SHELL in
/bin/mksh) /bin/mksh)
PS1=$PS1'${HOSTNAME:=$(hostname -s)}\$ ' PS1=$PS1'${HOSTNAME:=$(hostname -s)}\$ '
;; ;;
*) PS1=$PS1'\h\$ ' *)
PS1=$PS1'\h\$ '
;; ;;
esac esac
export PS1 export PS1
case $(uname -s) in case $(uname -s) in
Linux) stty erase "^?" Linux)
stty erase "^?"
;; ;;
esac esac

View File

@ -19,9 +19,9 @@ setxkbmap \
xset r rate 300 75 xset r rate 300 75
xset b off xset b off
test -d /usr/local/share/fonts/bitmaps \ test -d /usr/local/share/fonts/bitmaps &&
&& xset +fp /usr/local/share/fonts/bitmaps \ xset +fp /usr/local/share/fonts/bitmaps &&
&& xset fp rehash xset fp rehash
test -r ~/.Xresources && xrdb -merge ~/.Xresources test -r ~/.Xresources && xrdb -merge ~/.Xresources
exec herbstluftwm -l >~/local/var/log/herbstluftwm 2>&1 exec herbstluftwm -l >~/local/var/log/herbstluftwm 2>&1