1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/sh case "$(file --mime-type -Lb "$1")" in text/*) exec $EDITOR -- "$@" ;; *) for file in "$@"; do fork xdg-open "$file" done ;; esac