Files
not-much-fuzz/src/sh/notmuch.sh

54 lines
1.3 KiB
Bash

# Wrapper around notmuch
# notmuch new
# This is used for updating the notmuch database
nm_new() {
$NOTMUCH new
}
# Print the message id of the last message within a thread.
# @argument $1: thread id
nm_last_message_in_thread() {
# TODO: We may be smarter here that just incorporating excluded messages
$NOTMUCH search --output=messages --offset=-1 thread:"$1" | sed 's/^...//'
}
# Print the header of a message (with trailing empty line)
# @argument $1: message id
nm_message_header() {
$NOTMUCH show --body=false id:"$1" | awk "$AWK_MESSAGEHEADER"
}
# Print the message parts (with indents)
# @argument $1: message id
nm_message_parts() {
$NOTMUCH show --body=true id:"$1" | awk "$AWK_MESSAGEPARTS"
}
# Print the message part number for text/plain or text/html
# @argument $1: message id
# @argument $2: if set, then the html part number will be printed
nm_message_part_nr() {
$NOTMUCH show --body=true id:"$1" | awk -v html="${2:-}" "$AWK_PARTNR"
}
# Print part of message
# @argument $1: message id
# @argument $2: part number
nm_message_get_part() {
$NOTMUCH show --part="$2" id:"$1"
}
# Add/remove a tag
# @argument $1: [+/-]tag
# @argument $2: query
nm_tag() {
$NOTMUCH tag "$1" "$2"
}
# Get all files, also of excluded matches
# @argument $1: query
nm_files_all() {
$NOTMUCH search --output=files --exclude=false "$1"
}