Nice idea, but I use mc to navigate and it does it for me.
Just for people not familiar with "MidnightCommander"....
I've been using mc to do this under linux. The mc.ext file is loaded with regexes to autostart programs. All I need is to
hit 'enter' on the file. Of course, your checking of mime types
gives more flexibility in naming(no extension worries),
include/image
# Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (ee %f &); fi
Open= xv %f 2>&1>/dev/null &
View=%view{ascii} identify %f
#View=%view{ascii} asciiview %f