BrowserMacros.jl

Julia macros to surf the web from the comfort of your REPL.

Installation

To install BrowserMacros, open the Julia REPL and run

julia> ]add BrowserMacros

BrowserMacros currently requires Julia ≥1.7 and is in early development, so there will be a lot of edge-cases to iron out.

Functionality

GitHub

The highlight of this package is the macro @wwwhich ("world-wide-which"). It is almost identical to @which, but will open a new GitHub tab in your browser, showing the the exact line of code that is run:

@wwwhich sqrt(2.0)

This also works with code from external packages! Since @wwwhich opens a permalink, it is perfectly suited for sharing code.

The @issue macro will open an issue draft including the project dependencies and the Julia version info:

using Distributions

@issue Normal()

Search engines

Several search engines can be queried from your REPL:

@google "How to write macros in Julia"

For each macro, a corresponding function is also exported. The search engines currently include:

Name Macro
arXiv @arxiv
Baidu @baidu
Bing @bing
Brave @brave
ChatGPT @chatgpt
DuckDuckGo @ddg
Ecosia @ecosia
GitHub @github
Goodreads @goodreads
Google @google
Google Scholar @scholar
JuliaHub @juliahub
Julia Discourse @discourse
Julia Zulip @zulip
Qwant @qwant
Stack Overflow @stackoverflow
Web Archive @webarchive
Wikipedia @wikipedia
Wolfram Alpha @wolframalpha
Yahoo @yahoo
Yandex @yandex
YouTube @youtube

Please open an issue if your favorite search engine is missing!

How does it work?

BrowserMacros constructs URLs and opens them using DefaultApplication.jl. @wwwhich works by

  1. finding the corresponding method using InteractiveUtils' which
  2. determining the UUID and the version of the module containing the method
  3. looking up the UUID in the reachable registries to find the matching GitHub repository
  4. constructing a permalink to the relevant line of code

To-Do

  • Support for packages hosted on GitLab, SourceHut & Co.

Contributions are more than welcome!