Unify shell script style
This commit is contained in:
parent
8d3ae231bb
commit
c84c0e3a99
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# ZZZ
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# browser
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# credentials
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -12,10 +12,7 @@
|
|||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat - <<. >&2
|
printf "Usage: %s [-2pu] service\n" "${0##*/}" >&2
|
||||||
Usage:
|
|
||||||
${0##*/} [-2pu] service
|
|
||||||
.
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# fetch
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -9,9 +9,10 @@
|
|||||||
# warranty. You should have received a copy of the CC0 Public Domain
|
# warranty. You should have received a copy of the CC0 Public Domain
|
||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
printf "Usage: %s [-T] URL [URLs...]\n" "${0##*/}">&2
|
printf "Usage: %s [-T] URL [URL ...]\n" "${0##*/}">&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +35,7 @@ while getopts T flag; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
if [ $# -eq 0 ]; then
|
[ $# -gt 0 ] || usage
|
||||||
usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
: ${ARCHIVE_BASEDIR:=~/tmp/archive}
|
: ${ARCHIVE_BASEDIR:=~/tmp/archive}
|
||||||
mkdir -p "$ARCHIVE_BASEDIR"
|
mkdir -p "$ARCHIVE_BASEDIR"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# imgresize
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -10,7 +10,8 @@
|
|||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
usage() {
|
usage()
|
||||||
|
{
|
||||||
cat - <<. >&2
|
cat - <<. >&2
|
||||||
Usage:
|
Usage:
|
||||||
${0##*/} size in-file out-file
|
${0##*/} size in-file out-file
|
||||||
@ -20,24 +21,21 @@ Usage:
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
check_dimension_format() {
|
err()
|
||||||
|
{
|
||||||
|
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_dimension_format()
|
||||||
|
{
|
||||||
printf "%s\n" "$1" | grep -q "^[0-9]*x[0-9]*\$" \
|
printf "%s\n" "$1" | grep -q "^[0-9]*x[0-9]*\$" \
|
||||||
&& [ "$1" != "x" ]
|
&& [ "$1" != "x" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -ne 3 ] || ! check_dimension_format "$1"; then
|
[ $# -eq 3 ] && check_dimension_format "$1" || usage
|
||||||
usage
|
[ -n "$2" ] || err "Input file name can't be empty."
|
||||||
fi
|
[ -n "$3" ] || err "Output file name can't be empty."
|
||||||
if [ -z "$2" ]; then
|
|
||||||
printf "%s: Input file name can't be empty.\n" \
|
|
||||||
"${0##*/}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "$3" ]; then
|
|
||||||
printf "%s: Output file name can't be empty.\n" \
|
|
||||||
"${0##*/}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
size=$1
|
size=$1
|
||||||
w=${size%x*}
|
w=${size%x*}
|
||||||
@ -52,8 +50,7 @@ case $infile in
|
|||||||
;;
|
;;
|
||||||
*.png) inprog=pngtopam
|
*.png) inprog=pngtopam
|
||||||
;;
|
;;
|
||||||
*) printf "%s: Unknown input format.\n" "${0##*/}" >&2
|
*) err "Unknown input format."
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -64,8 +61,7 @@ case $outfile in
|
|||||||
;;
|
;;
|
||||||
*.png) outprog=pamtopng
|
*.png) outprog=pamtopng
|
||||||
;;
|
;;
|
||||||
*) printf "%s: Unknown output format.\n" "${0##*/}" >&2
|
*) err "Unknown output format."
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# invidious
|
||||||
# Written in 2019 by Leslie
|
# Written in 2019 by Leslie
|
||||||
# Modified in 2019 by Lucas
|
# Modified in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
@ -11,20 +11,25 @@
|
|||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
usage() {
|
usage()
|
||||||
|
{
|
||||||
printf "Usage: %s url\n" "${0##*/}" >&2
|
printf "Usage: %s url\n" "${0##*/}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -ne 1 ]; then
|
err()
|
||||||
usage
|
{
|
||||||
fi
|
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ $# -eq 1 ] || usage
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"https://invidio.us/watch?v="*)
|
"https://invidio.us/watch?v="*)
|
||||||
;;
|
;;
|
||||||
*) printf "%s: Not an invidio.us url.\n" "${0##*/}" >&2
|
*) err "Not an invidio.us url."
|
||||||
exit 1
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
video_id=
|
video_id=
|
||||||
@ -34,21 +39,17 @@ for param in $(printf "%s\n" "${1##*"?"}" | tr "&" "\n"); do
|
|||||||
|
|
||||||
v=${param#*=}
|
v=${param#*=}
|
||||||
if [ ${#v} -ne 11 ]; then
|
if [ ${#v} -ne 11 ]; then
|
||||||
printf "%s: "%s": not a video id.\n" "${0##*/}" "$v" >&2
|
printf "%s: \"%s\": not a video ID." "${0##*/}" "$v" >&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
video_id=$v
|
video_id=$v
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$video_id" ]; then
|
[ -n "$video_id" ] || err "no video ID in URL."
|
||||||
printf "%s: no video ID in URL.\n" "${0##*/}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dl_option=$(ftp -o - "$1" 2>/dev/null \
|
dl_option=$(ftp -o - "$1" 2>/dev/null | grep -F "<option value='{" |
|
||||||
| grep "<option value='{" \
|
head -n 1 | cut -d "\"" -f 8)
|
||||||
| head -n 1 | cut -d "\"" -f 8)
|
|
||||||
|
|
||||||
printf "https://invidio.us/latest_version?id=%s&itag=%s\n" \
|
printf "https://invidio.us/latest_version?id=%s&itag=%s\n" \
|
||||||
"$video_id" "$dl_option"
|
"$video_id" "$dl_option"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# rfcopen
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -10,12 +10,20 @@
|
|||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
usage() {
|
usage()
|
||||||
|
{
|
||||||
printf "Usage: %s [-T] rfc-number\n" "${0##*/}" >&2
|
printf "Usage: %s [-T] rfc-number\n" "${0##*/}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
tonumber() {
|
err()
|
||||||
|
{
|
||||||
|
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
tonumber()
|
||||||
|
{
|
||||||
printf "%u" "$1" 2>/dev/null
|
printf "%u" "$1" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,18 +40,13 @@ while getopts T flag; do
|
|||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
if [ $# -ne 1 ] || [ -z "$1" ] || ! n=$(tonumber "$1"); then
|
[ $# -eq 1 ] && [ -n "$1" ] && n=$(tonumber "$1") || usage
|
||||||
usage
|
|
||||||
fi
|
|
||||||
rfcfile=$RFCDIR/rfc$n.txt
|
rfcfile=$RFCDIR/rfc$n.txt
|
||||||
url=https://tools.ietf.org/rfc/rfc$n.txt
|
url=https://tools.ietf.org/rfc/rfc$n.txt
|
||||||
|
|
||||||
mkdir -p "$RFCDIR"
|
mkdir -p "$RFCDIR"
|
||||||
if [ ! -f "$rfcfile" ]; then
|
if [ ! -f "$rfcfile" ]; then
|
||||||
if ! $torsocks ftp -Vo "$rfcfile" "$url"; then
|
$torsocks ftp -Vo "$rfcfile" "$url" || err "Couldn't fetch RFC $n."
|
||||||
printf "%s: Couldn't fetch RFC %u\n" "${0##*/}" "$n" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${PAGER:-more} "$rfcfile"
|
${PAGER:-more} "$rfcfile"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# screenshot
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -10,7 +10,8 @@
|
|||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
usage() {
|
usage()
|
||||||
|
{
|
||||||
cat - <<. >&2
|
cat - <<. >&2
|
||||||
Usage:
|
Usage:
|
||||||
${0##*/}
|
${0##*/}
|
||||||
@ -21,30 +22,25 @@ Usage:
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
save_screenshot() {
|
err()
|
||||||
|
{
|
||||||
|
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
save_screenshot()
|
||||||
|
{
|
||||||
xwdtopnm | pnmtopng >~/media/ss/"$(date +%Y%m%d-%H%M%S)".png
|
xwdtopnm | pnmtopng >~/media/ss/"$(date +%Y%m%d-%H%M%S)".png
|
||||||
}
|
}
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
0) xwd -silent -root | save_screenshot
|
0) xwd -silent -root | save_screenshot
|
||||||
;;
|
;;
|
||||||
1) if [ "$1" != "-window" ]; then
|
1) [ "$1" = "-window" ] || err "Unknown option \"$1\"."
|
||||||
printf "%s: Unknown option \"%s\".\n" \
|
|
||||||
"${0##*/}" "$1" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
xwd -silent | save_screenshot
|
xwd -silent | save_screenshot
|
||||||
;;
|
;;
|
||||||
2) if [ "$1" != "-id" ] && [ "$1" != "-name" ]; then
|
2) [ "$1" = "-id" ] || [ "$1" = "-name" ] || err "Unknown option \"$1\"."
|
||||||
printf "%s: Unknown option \"%s\".\n" \
|
[ -n "$2" ] || err "$1 expects a non-empty parameter."
|
||||||
"${0##*/}" "$1" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "$2" ]; then
|
|
||||||
printf "%s: %s expects a non-empty parameter.\n" \
|
|
||||||
"${0##*/}" "$1" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
xwd -silent "$1" "$2" | save_screenshot
|
xwd -silent "$1" "$2" | save_screenshot
|
||||||
;;
|
;;
|
||||||
*) usage
|
*) usage
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# tor-browser
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# w3m-copy-link
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# env
|
# xsekrit
|
||||||
# Written in 2019 by Lucas
|
# Written in 2019 by Lucas
|
||||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
#
|
#
|
||||||
@ -10,12 +10,18 @@
|
|||||||
# Dedication along with this software. If not, see
|
# Dedication along with this software. If not, see
|
||||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
if [ $# -ne 1 ] || [ -z "$1" ]; then
|
usage()
|
||||||
|
{
|
||||||
printf "Usage: %s key\n" "${0##*/}" >&2
|
printf "Usage: %s key\n" "${0##*/}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
if ! sekrit has "$1"; then
|
|
||||||
printf "%s: Unknown key \"%s\".\n" "${0##*/}" "$1" >&2
|
err()
|
||||||
|
{
|
||||||
|
printf "%s: %s\n" "${0##*/}" "$*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
[ $# -eq 1 ] && [ -n "$1" ] || usage
|
||||||
|
sekrit has "$1" || err "Unknown key \"$1\"."
|
||||||
sekrit get "$1" | xclip -q -r -l 1 -sel clip 2>/dev/null
|
sekrit get "$1" | xclip -q -r -l 1 -sel clip 2>/dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user