Last active
January 24, 2020 04:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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