Last active
December 12, 2019 17:11
-
-
Save pszucs/4faf05f9e35b7e4c3ed635abf097c871 to your computer and use it in GitHub Desktop.
Adding subl// handlers Ignition error page links to Sublime Text 3
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
Based on | |
- https://github.com/toch/subl-handler | |
- https://askubuntu.com/questions/250847/sublime-text-url-handler-for-ubuntu | |
A link to a file on an Ignition error page looks like this: | |
subl://open?url=file://%2Fvar%2Fwww%2Fprojects%2Froutes%2Fweb.php&line=439 | |
Create the following installer somewhere in your home folder (this script uses $HOME/bin), then make it executable and run it: | |
#!/bin/bash | |
mkdir -p $HOME/bin | |
cat > $HOME/bin/subl-handler <<EOF | |
#!/bin/bash | |
request="${1#*://}" # Remove schema from url (subl://) | |
request="${request#*?url=file://}" # Remove open?url=file:// | |
request="${request//%2F//}" # Replace %2F with / | |
request="${request/&line=/:}" # Replace &line= with : | |
subl "$request" # Launch sublime | |
EOF | |
chmod u+x $HOME/bin/subl-handler | |
mkdir -p $HOME/.local/share/applications/ | |
cat > $HOME/.local/share/applications/subl-handler.desktop <<EOF | |
[Desktop Entry] | |
Name=subl-handler | |
Comment=Sublime Text URI scheme subl:// handler | |
Exec=$HOME/bin/subl-handler %u | |
Terminal=0 | |
Type=Application | |
X-MultipleArgs=True | |
MimeType=x-scheme-handler/subl | |
Encoding=UTF-8 | |
Categories=Application; | |
EOF | |
update-desktop-database $HOME/.local/share/applications/ | |
xdg-mime default subl-handler.desktop x-scheme-handler/subl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment