# Copyright © 2013 Jani Nikula
#
# Based on the bash-completion package:
-# http://bash-completion.alioth.debian.org/
+# https://github.com/scop/bash-completion
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see http://www.gnu.org/licenses/ .
+# along with this program. If not, see https://www.gnu.org/licenses/ .
#
# Author: Jani Nikula <jani@nikula.org>
#
sed 's/[^<]*<\([^>]*\)>/\1/' | tr "[:upper:]" "[:lower:]" | sort -u
}
+_notmuch_mimetype()
+{
+ # use mime types from mime-support package if available, and fall
+ # back to a handful of common ones otherwise
+ if [ -r "/etc/mime.types" ]; then
+ sed -n '/^[[:alpha:]]/{s/[[:space:]].*//;p;}' /etc/mime.types
+ else
+ cat <<EOF
+application/gzip
+application/msword
+application/pdf
+application/zip
+audio/mpeg
+audio/ogg
+image/gif
+image/jpeg
+image/png
+message/rfc822
+text/calendar
+text/html
+text/plain
+text/vcard
+text/x-diff
+text/x-vcalendar
+EOF
+ fi
+}
+
_notmuch_search_terms()
{
local cur prev words cword split
COMPREPLY=( $(compgen -d "$path/${cur##folder:}" | \
sed "s|^$path/||" | grep -v "\(^\|/\)\(cur\|new\|tmp\)$" ) )
;;
+ mimetype:*)
+ compopt -o nospace
+ COMPREPLY=( $(compgen -P "mimetype:" -W "`_notmuch_mimetype ${cur}`" -- ${cur##mimetype:}) )
+ ;;
*)
local search_terms="from: to: subject: attachment: mimetype: tag: id: thread: folder: path: date: lastmod:"
compopt -o nospace