From 6e29de366cadd79b66b8e8eb1426cff06d407074 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 20 Nov 2011 16:05:12 +0000 Subject: Missed file. --- Functions/MIME/zsh-mime-contexts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Functions/MIME/zsh-mime-contexts diff --git a/Functions/MIME/zsh-mime-contexts b/Functions/MIME/zsh-mime-contexts new file mode 100644 index 000000000..08f125158 --- /dev/null +++ b/Functions/MIME/zsh-mime-contexts @@ -0,0 +1,24 @@ +# Helper for zsh-mime-handler. +# +# Pass in a zstyle option, a suffix, which might include multiple parts +# (e.g. pdf.gz), plus remaining zstyle arguments plus arguments to zstyle. +# Try to match the style starting with the longest possible suffix. + +local context suffix option + +option=$1 +shift +suffix=$1 +shift + +while true; do + context=":mime:.${suffix}:" + zstyle $option $context "$@" && return 0 + if [[ $suffix = *.* ]]; then + suffix=${suffix#*.} + else + break + fi +done + +return 1 -- cgit 1.4.1