Skip to content

Instantly share code, notes, and snippets.

@salman-abedin
Last active September 7, 2023 12:12
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save salman-abedin/6f52c52e465d89d489f9ea8d891c7332 to your computer and use it in GitHub Desktop.
Save salman-abedin/6f52c52e465d89d489f9ea8d891c7332 to your computer and use it in GitHub Desktop.
XDG Alternative
#!/bin/sh
#
# Launches files based on their mimetypes
# Usage: launch [FILE...]
# Dependencies: file
case $(file --mime-type "$@" -bL) in
# Check for the mimetype of your file (This is POSIX regex)
video/* | audio/* | image/gif)
# Launch using your favorite application
devour mpv "$@"
;;
# So on and so forth...
application/pdf | application/postscript)
devour zathura "$@"
;;
*) exit 1 ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment