-
-
Save Tuxliri/6daf8a25092ed51e59d68db92813e2c8 to your computer and use it in GitHub Desktop.
Open browser based off of certain rules (like choosy for macOS)
This file contains hidden or 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/bash | |
| URL=$1 | |
| DOMAIN=$(echo "$URL" | awk -F[/:] '{print $4}') | |
| ## Domain starts with | |
| if [[ $DOMAIN =~ $(echo ^\($(paste -sd'|' /home/your-user/.config/url-start.txt)\)$) ]]; then | |
| microsoft-edge "$URL" & disown | |
| elif [[ $DOMAIN =~ $(echo ^\($(paste -sd'|' /home/your-user/.config/url-is.txt)\)$) ]]; then | |
| microsoft-edge "$URL" & disown | |
| else | |
| firefox "$URL" & disown | |
| fi |
This file contains hidden or 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
| [Desktop Entry] | |
| Name=Choosy | |
| GenericName=Browser Chooser | |
| Comment=Choose what browser to use for specific links | |
| Categories=Network; | |
| Exec=choosy %u | |
| Type=Application | |
| MimeType=x-scheme-handler/unknown;x-scheme-handler/about;text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https; |
This file contains hidden or 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
This file contains hidden or 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
| localhost |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script allows one to set which browser handles which uri. This gist is forked from the work of @cesarolea and is here as reference for me and others. These instructions were tested on Ubuntu 22.04.
There are 2 files filtering the urls:
url-start.txtthere are the urls which are handled if there is a partial match e.g. if here we set the uridocs.google.com, then alsohttps://docs.google.com/user/davide/blablabla.docxwill be handled by the selected browserurl-is.txthere the urls are matched only exactlyInstallation
choosy, replacingyour-userwith your usernamechoosy(in my example here I have microsoft edge handling the two filtered cases and firefox handling all other urlschoosyto your path and make it executable~/.local/share/applications/or/usr/share/applications/:cp choosy.desktop ~/.local/share/applications/xdg-mime default choosy.desktop x-scheme-handler/http && xdg-mime default choosy.desktop x-scheme-handler/httpsin the terminal to set the association.url-start.txtandurl-is.txtto your ~/.config folder:cp url-* ~/.config