citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

commit 7b5621cfbd18c4abead470803d60cad11f97607e
parent 00b92a60e56d3867c0c1580f86ac2f8c493ae342
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 20 Nov 2020 11:21:27 -0800

various updates

Diffstat:
Mbin/fuzz-compile | 11+++++++++--
Abin/mbox-pretty | 8++++++++
Mbin/notmuch-thread-reader | 3++-
Abin/sortmail | 13+++++++++++++
4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/bin/fuzz-compile b/bin/fuzz-compile @@ -2,5 +2,12 @@ set -eou pipefail -make_target=$(fuzz-make "$@") -echo make -j $make_target \2\>\&\1\| tee .build-result +if [ -f package.json ] && [ ! -f Makefile ]; then + target=$(jq -r '.scripts | keys[]' package.json | fuzzer "$@") + echo npm run $target \2\>\&\1\| tee .build-result +else + target=$(fuzz-make "$@") + echo make -j $target \2\>\&\1\| tee .build-result +fi + + diff --git a/bin/mbox-pretty b/bin/mbox-pretty @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +script=$(cat <<EOF +/^X-/d; +EOF +) + +exec sed -E "$script" diff --git a/bin/notmuch-thread-reader b/bin/notmuch-thread-reader @@ -4,5 +4,6 @@ if [ -z $1 ]; then printf "usage: notmuch-thread-reader <thread-id>\n" exit 1 fi -notmuch show $1 | notmuch-show-pretty > /tmp/$1 +notmuch show --format=mbox $1 > /tmp/$1 +sortmail /tmp/$1 lessr /tmp/$1 diff --git a/bin/sortmail b/bin/sortmail @@ -0,0 +1,13 @@ +#!/usr/bin/env python +from email.utils import parsedate +import sys +import mailbox + +def extract_date(email): + date = email.get('Date') + return parsedate(date) + +the_mailbox = mailbox.mbox(sys.argv[1]) +sorted_mails = sorted(the_mailbox, key=extract_date) +the_mailbox.update(enumerate(sorted_mails)) +the_mailbox.flush()