From 4d486cf94d3fcfe4f07daf7dc65c9de04c7cfdd5 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 2 Nov 2016 20:46:47 +0200 Subject: [PATCH] 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. --- completion/notmuch-completion.bash | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 <