Skip to content

Instantly share code, notes, and snippets.

@peterrosell
Last active March 26, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterrosell/bf44a86cf0c6df920ce88a01c828cfdc to your computer and use it in GitHub Desktop.
Save peterrosell/bf44a86cf0c6df920ce88a01c828cfdc to your computer and use it in GitHub Desktop.
Register a schema handler to open links from GoConvey in Visual Studio Code. Works at least for Ubuntu 16.04.
#!/usr/bin/env bash
cat <<EOF-HANDLER > /usr/bin/goconvey-handler
#!/usr/bin/env bash
request="\${1#*://}" # Remove schema from url (goconvey://)
request="\${request#*?url=}" # Remove open?url=
request="\${request#*://}" # Remove file://
request="\${request//%2F//}" # Replace %2F with /
request="\${request/&line=/:}" # Replace &line= with :
request="\${request/&column=/:}" # Replace &column= with :
if [ -n "\${GOCONVEY_EDITOR}" ]; then
\$GOCONVEY_EDITOR \$GOCONVEY_EDITOR_FLAGS "\$request" # Launch specified goconvey editor
elif [ -n "\${EDITOR}" ]; then
\$EDITOR \$GOCONVEY_EDITOR_FLAGS "\$request" # Launch default editor
else
code -g "\$request" # Launch code as editor
fi
EOF-HANDLER
cat <<EOF-DESKTOP > /usr/share/applications/goconvey-handler.desktop
[Desktop Entry]
Name=GoConvey URL Handler
GenericName=Text Editor
Comment=Handle URL Scheme goconvey://
Exec=/usr/bin/goconvey-handler %u
Terminal=false
Type=Application
MimeType=x-scheme-handler/goconvey;
Icon=code
Categories=TextEditor;Development;Utility;
Name[en_US]=GoConvey URL handler
EOF-DESKTOP
chmod +x /usr/bin/goconvey-handler
update-desktop-database
xdg-mime default /usr/share/applications/goconvey-handler.desktop x-scheme-handler/goconvey
@peterrosell
Copy link
Author

This script installs a custom schema handler in Ubuntu that handles the links in GoConvey's web GUI.
It uses your default editor if the environment variable EDITOR is set.
If you like to use a separate editor just for goconvey links, you can set GOCONVEY_EDITOR.
Some editor need extra flags to handle filenames with line number. These flags can be set in GOCONVEY_EDITOR_FLAGS.
If no editor environment variables are set it defaults to Visual Studio Code.

This script is tested on Ubuntu 16.04 with Unity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment