diff options
| author | Jani Nikula <jani@nikula.org> | 2016-11-02 20:46:47 +0200 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2016-11-12 07:33:36 -0400 |
| commit | 4d486cf94d3fcfe4f07daf7dc65c9de04c7cfdd5 (patch) | |
| tree | c39f980258ca29ccd23f6617950bb0d4ab2dfd42 /completion | |
| parent | 343534d82dc8882b3f0e2a847ee9d10ba5392809 (diff) | |
completion: complete mimetype: search prefix
Use /etc/mime.types if available, parsed using a sed one-liner, and
fall back to a handful of common types otherwise.
Diffstat (limited to 'completion')
| -rw-r--r-- | completion/notmuch-completion.bash | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index 78047b5f..d44b2a28 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -58,6 +58,34 @@ _notmuch_email() 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 @@ -85,6 +113,10 @@ _notmuch_search_terms() 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 |
