Merge remote-tracking branch 'origin/wip-refactor' into lappy

This commit is contained in:
Daniel Flanagan 2020-01-07 10:58:29 -06:00
commit aa29acb364
7 changed files with 84 additions and 3 deletions

View File

@ -16,6 +16,7 @@ alias tree='tree -Csuh'
alias f='fzf'
alias cp="rsync -ah --progress"
alias year="cal $(date +%Y)"
alias y="year"
# gets the newest function for the current directory (or the specified directory
# if one is provided)

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
archive_name="${1}.tar.gz"; shift
tar czvf "${archive_name}" ${@}
archive_name="${1}.tar.zstd"; shift
tar --zstd -cvf "${archive_name}" ${@}
echo "Archive created at: ${archive_name}"

3
bin/compress Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
zstd "$@"

3
bin/decompress Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
unzstd "$@"

73
bin/email-via-mailgun-smtp Executable file
View File

@ -0,0 +1,73 @@
#!/usr/bin/env bash
err() {
errpre=""
errpost=""
if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
errpre="$(tput setaf 1)"
errpost="$(tput setaf 7)"
fi
fi
>&2 echo "${errpre}ERROR: $@${errpost}"; usage; exit 1
}
warn() {
pre=""
post=""
if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
pre="$(tput setaf 3)"
post="$(tput setaf 7)"
fi
fi
>&2 echo "${pre}WARNING: $@${post}"
}
usage() { >&2 cat <<USAGEDOC
usage:
email-via-mailgun-smtp [recipient] [subject] [username] [password] <<< 'Hello, world!'
email-via-mailgun-smtp will read all the input from stdin and use the contents as the body of the email.
recipient will default to DEFAULT_MAILGUN_SMTP_RECIPIENT if not set
username will default to DEFAULT_MAILGUN_SMTP_USERNAME if not set
password will default to DEFAULT_MAILGUN_SMTP_PASSWORD if not set
subject will default to DEFAULT_MAILGUN_SMTP_SUBJECT if not set
USAGEDOC
}
recipient="${1:-$DEFAULT_MAILGUN_SMTP_RECIPIENT}"; shift
[[ -z $recipient ]] && err 'No recipient provided.'
subject="${1:-$DEFAULT_MAILGUN_SMTP_SUBJECT}"; shift
[[ -z $subject ]] && warn 'No subject provided. Leaving blank.'
username="${1:-$DEFAULT_MAILGUN_SMTP_USERNAME}"; shift
[[ -z $username ]] && err 'No username provided.'
password="${1:-$DEFAULT_MAILGUN_SMTP_PASSWORD}"; shift
[[ -z $password ]] && err 'No password provided.'
warn "Reading email body from stdin..."
body=""
while read -r line; do
body="${body}\n${line}"
done
[[ -z $body ]] && err 'Body was blank.'
echo "Recipient: $recipient"
>&2 echo "Finished reading body. Sending email..."
swaks --auth \
--server smtp.mailgun.org \
--au "$username" \
--ap "$password" \
--to "$recipient" \
--h-Subject: "$subject" \
--body "$body"

View File

@ -49,6 +49,7 @@ pacaur --needed -S \
docker docker-compose `# Yummy containers` \
inotify-tools `# Watching` \
luajit lua luarocks `# Lua` \
swaks `# SMTP CLI` \
--noconfirm --noedit
# install rxvt-unicode script for resizing font on-the-fly

View File

@ -4,6 +4,6 @@ archive_name="${1}"; shift
to_dir="$(basename $archive_name)"
mkdir -p "${to_dir}"
pushd "${to_dir}"
tar xzvf "${archive_name}"
tar --zstd -xvf "${archive_name}"
echo "Unarchived to: ${to_dir}"
popd