Skip to content

Instantly share code, notes, and snippets.

@iglosiggio
Last active January 24, 2020 04:58
Show Gist options
  • Save iglosiggio/7eb461bc9d2112a651ec9a749f3b9e99 to your computer and use it in GitHub Desktop.
Save iglosiggio/7eb461bc9d2112a651ec9a749f3b9e99 to your computer and use it in GitHub Desktop.
Simple shell script that opens an http/https after querying the server for the Content-Type
#!/bin/sh
# If you want to query the server for the mime uncomment the following line
#mime="$(curl -s -I "$1" | sed '/^content-type/I{s/content-type: //I; s/;.*$//; p};d' | tr -d '\r\n')"
# If you want to guess the mime uncomment the following line (requires perl-file-mimeinfo)
mime=$(mimetype -b "$1")
app="$(xdg-mime query default "${mime:-text/html}")"
gtk-launch "$app" $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment