Lokyr
Documentation

Links

On this page

macOS · on by default · the links plugin · [links], [plugins.links]

⌘-click a URL, a path or a program's link to open it, without copying it first. A path followed by a line number, such as a compiler's error, opens at that line in your editor. From the keyboard, hints label every link on the screen, so that a letter or two opens one.

Try it

Run this command:

echo "Read https://lokyr.dev/docs/ or /etc/hosts"

Hold ⌘ and move the pointer over the address: it's underlined, and the pointer becomes a pointing hand. Click: Lokyr asks whether to open it, then opens it in your browser.

What it gives you

While you hold ⌘, the link under the pointer is underlined, so that you see what a click would open. These open:

A URL opens in your browser or your mail app, a file in its app, and a folder in the Finder. A program, an app or a script never runs: the Finder shows it, selected.

Try it: run this command, which prints a link the way programs do:

printf '\033]8;;https://lokyr.dev/\033\\the site\033]8;;\033\\\n'

⌘-click the site: https://lokyr.dev/ opens.

Open a path at its line in your editor

Compilers, test runners, grep -n and AI agents write a path with its line, and sometimes its column. Lokyr underlines them together, in each of these forms:

FormExample
A colon and the linesrc/main.rs:42
The line and the columnsrc/main.rs:42:7
Between parenthesessrc/app.ts(42,7)
A fragment, as on the websrc/main.rs#L42

By default, the file opens in its app, at no line. Name your editor in [links] editor, and the file opens there, at its line and column:

[links]
editor = "vscode"   # or "cursor", "zed", "sublime", "textmate", and more

For another editor, give the address that it answers to, with {path}, {line} and {column} where they go:

[links]
editor = "jetbrains://idea/navigate/reference?path={path}&line={line}"

A file opens in your editor even when a terminal claims its type, such as a script, as nothing runs. Where the editor isn't installed, the file opens in its app.

Try it: with editor = "vscode" in your config, run echo /etc/hosts:3 and ⌘-click the path: VS Code opens the file at line 3.

Choose whether Lokyr asks first

Before it opens a URL or a file, Lokyr asks you, showing it in full, so that a link whose text says something else can't surprise you. A folder opens at once.

The checkboxes write urls and files in your config, which you can also set yourself:

[links]
urls = "open"      # "ask" asks first
files = "reveal"   # "ask" asks first, "open" opens the file in its app

Try it: ⌘-click /etc/hosts in the output of Try it above: the question offers Open, Show in Finder and Cancel. Click Show in Finder: the Finder shows the file, selected.

Use the context menu

Right-click a link, a URL or a path, or ⌃-click it, for these items:

An item that doesn't apply is dimmed: a URL of the web has no folder. For a selection of one line, the menu also has Search the Web, which opens the search engine that search-engine names.

Try it: run echo /usr/share/man, right-click the path and choose New Tab at Folder: a tab opens, its shell in /usr/share/man.

Platforms: macOS · Since 1.3

Press ⇧⌘E, or choose View › Show Hints. Every URL, every path that exists, with or without its line, every git hash and every IP address on the screen is underlined, and gets a label of one or two letters over its first letters. The labels nearest the cursor are a single letter. Type a label to pick its hint:

Typing a label's first letter keeps the labels that start with it. Escape, or a click elsewhere, takes the labels away.

Hints also find a URL right after a bracket, a quote or a =, such as in Markdown's [docs](https://…) or HTML's href="https://…", and a path with spaces between quotes or after backslashes. alphabet sets the labels' letters, and the theme's hints.label.bg and hints.label.fg their colors.

Try it: run this command, then press ⇧⌘E:

echo "https://lokyr.dev/docs/ /etc/hosts 10.0.0.1 3fa2b9c"

The four get a label on the output's line, and on the command line above it too. Type a label of the URL with Shift: the labels go, and pbpaste prints https://lokyr.dev/docs/.

Add your own patterns

Platforms: macOS · Since 1.3

Besides URLs, paths, hashes and addresses, the hints can label text of your own, such as your issue tracker's ticket numbers, and open a page for each. Each pattern is a table of the config, under [plugins.links.hints], named as you like:

# A ticket number, such as PROJ-1234, opens the ticket's page.
[plugins.links.hints.tickets]
pattern = 'PROJ-\d+'
url = "https://jira.example.com/browse/$0"

Try it: add the table above to your config and save it, then run this command and press ⇧⌘E:

echo "Fixed in PROJ-42, see PROJ-7 too"

PROJ-42 and PROJ-7 get a label each, and typing a label opens https://jira.example.com/browse/PROJ-42 or https://jira.example.com/browse/PROJ-7.

When only part of the match goes into the URL, put that part between parentheses and use $1. The ticket's number alone, for example:

# PROJ-1234 opens https://tracker.example.com/issue?id=1234.
[plugins.links.hints.tracker]
pattern = 'PROJ-(\d+)'
url = "https://tracker.example.com/issue?id=$1"

More patterns:

# A GitHub issue, such as #128, of one repository.
[plugins.links.hints.issues]
pattern = '#(\d+)'
url = "https://github.com/acme/app/issues/$1"

# A UUID, which picking copies.
[plugins.links.hints.uuids]
pattern = '(?i)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'

A pattern that doesn't read is left out, and a notice reports why. A pick that fails, such as a url that starts with $0 and turns into a URL that doesn't open, shows a notice too, and the labels go. The hints key of the configuration guide lists the same rules.

You can also add, change and remove your patterns in the settings window, which Lokyr › Open Settings Window opens, under Hints in its Links section:

Lokyr writes each pattern to your config file as a table of its own, such as [plugins.links.hints.tickets], and keeps the rest of the file and its comments as they are.

Settings

[links]
urls = "ask"            # "open" opens URLs without asking
files = "ask"           # "open" or "reveal" without asking
editor = "system"       # the editor of a path's line, such as "vscode"
search-engine = "google"

[links] tells each key, and [plugins.links] the hints' alphabet and hints.

In the settings window, which Lokyr › Open Settings Window opens, the Links section holds these keys, and under Hints the hints' keys, your patterns among them. · Since 1.3

Commands and keys

KeysIn the configWhat they do
⌘-clickcmd+clickOpen the link under the pointer
⇧⌘Ecmd+shift+eShow the hints · Since 1.3
Tab, ⇧Tabtab, shift+tabChange what a pick does, while the hints show · Since 1.3

The links plugin lists its commands, those of no keys too, such as links.copy, which you can bind in [keys].

How it works

A program prints a link with OSC 8, hyperlinks in terminals: an escape code before the text gives the link, and another after it ends it. Lokyr keeps the link on the text's cells, and never shows the code. A file URL opens when it names this Mac: with no host, localhost or the Mac's name, as ls --hyperlink, ripgrep and fd write it.

For a URL or a path in the text, Lokyr reads the line under the pointer, joined across the rows that it wraps over, when you hold ⌘ or click. A relative path is read from the folder of the program in front, and opens only if it's there.

Hints read the screen's lines once, when you press ⇧⌘E, and cost nothing while they're hidden.

Limits

Troubleshooting

⌘-click on a path does nothing

Why: the path doesn't exist on this Mac, or it's relative to a folder other than the one of the program in front, such as a path that make prints from a subfolder.

Fix: run the command from the folder that the paths start from, or ⌘-click a path from /.

Check: hold ⌘ over the path: it's underlined.

A path with its line opens the file at its start

Why: editor is "system", which opens the file in its app, at no line.

Fix: name your editor:

[links]
editor = "vscode"

Check: ⌘-click the path again: the editor opens at the line.

A pattern of your own gets no labels

Platforms: macOS · Since 1.3

Why: the pattern doesn't read, its url starts with a scheme that doesn't open, or its backslashes were lost between double quotes. A notice reports the first two when you save the config.

Fix: write the pattern between single quotes, such as pattern = 'PROJ-\d+', and make the url start with https://.

Check: run echo PROJ-42 and press ⇧⌘E: PROJ-42 gets a label.

See also