Workspace
Links and the command line
Two ways into Clew from outside it. A clew:// link opens a
note at a heading or a line — from a task manager, a calendar entry, a
launcher, a web page — or makes today's diary entry. The
clew command does the same from a terminal, and exports a
note too. Both only open and create: neither runs a vault's code or
changes what you trust. (Neither is in 0.12.0, and neither is on the
iPad yet.)
clew:// links
A link to a heading
clew://open?vault=Research¬e=Projects/Grant%20proposal#Aims%20and%20scope
vault names the vault: the name of its folder, matched
ignoring case, for a vault this device already knows (one that is open
or on the recent list), or its full path — /Users/… or
~/…. Two known vaults with the same name are ambiguous, and
the link is refused with two vaults are called "Research" — name it
by its path. Leave vault out and the link means the
vault in front, or the last one you had open.
note is the note's path inside the vault, as the file
explorer shows it; .md is assumed when there is no
extension. After it, # and a heading lands on that heading,
or &line=12 on that line. A link is a URL, so a space
is written %20, as in the example. With no
note at all, clew://open?vault=Research just
brings that vault forward.
Today's diary entry, and a new note
clew://new?vault=Research&daily=1
clew://new?vault=Research¬e=Inbox/Call%20with%20Sam
new with daily=1 opens today's
diary entry, creating it if it is not
there yet. With a note it creates that note, empty — never
over a file: if Inbox/Call with Sam.md exists, the new one
is Call with Sam 1.md. Either way a notice says so —
Created Inbox/Call with Sam.md, from a clew link or command. —
so a note never appears unexplained.
Whatever a link opens goes into a tab of its own, or the tab already showing that note, and never replaces the note you were working on.
What a link can and cannot do
A link may sit on a web page or in an email you did not write, so
there are only two actions. open opens and navigates;
new makes an empty note or today's entry. Nothing else
happens:
- Anything else is refused by name.
clew://run?…shows A clew link was refused: clew://run is not something a link can do (open, new). - A link never runs code or changes trust. A vault opened by a link is exactly as trusted or restricted as it was before.
- A vault this device has not seen is asked about first: Open the vault "Elsewhere"? A clew:// link asked to open …, which Clew has not opened on this device. Opening it shows its notes; it does not trust its code. Cancel is the default. If you open it, it opens restricted, as any vault does the first time.
- A note path cannot leave the vault. A path with
..in it, or an absolute one, is refused, and a note that does not exist gets No note "…" in Research. rather than being made.
Where links work
An installed Clew registers itself as the handler for
clew:// links, so clicking one anywhere on the system
opens what the link names — starting Clew first if it is not running,
in the window Clew starts with rather than a second one. A Clew
run from its source code (npm run dev) does not register
on macOS — it would register the bare Electron app instead — so there
you give it the link on its command line:
electron . 'clew://open?vault=…'.
The clew command
Help → Install the clew Command… puts a
clew command where your terminal finds commands:
/usr/local/bin if your account may write there, otherwise
~/.local/bin. It never asks for an administrator's password,
and if the folder it used is not on your PATH the
confirmation says to add it. The command is for macOS and Linux; on
Windows the menu item says so.
In a terminal
clew open Projects/Grant\ proposal.md # a note, in its vault
clew open ~/Notes/Research # a vault
clew new --daily # today's diary entry
clew new "Inbox/Call with Sam" # a new, empty note
clew export --pdf Projects/Grant\ proposal.md # beside the note
clew export --pdf Projects/Grant\ proposal.md --out ~/Desktop/ # elsewhere
clew open <file or folder>- A folder opens as a vault. A file opens in its vault: the nearest
folder above it that holds
.clewor.obsidian, else a vault Clew knows that contains it, else its own folder. Relative paths are read from where you are. clew new --daily·clew new <note>- As the
newlink: today's entry, or an empty note at that path inside the vault, never over a file. Add--vault <name or path>to say which vault; without it, the vault in front, or the last one you had open. clew export --pdf|--latex|--html <note> [--out <file or folder>]- Exports the note as
File → Export would —
--pdfis PDF via LaTeX — and writes only the file asked for:Grant proposal.pdf,.texor.html, with a.texor.htmlthat has diagrams the export draws getting its-figures/folder beside it. A PDF is typeset in a temporary folder that is removed afterwards, so no LaTeX build files appear beside the note; its images and its bibliography are still found from the note's own folder. Without--outthe file goes beside the note.--outputs it elsewhere: a file name, or a folder — one that exists, or written with a trailing/— relative to where you run the command, with~meaning your home folder. If the PDF fails, the command says so with LaTeX's first error, and nothing is left beside the note. The export follows the vault's trust exactly as the menu's does: in a restricted vault, no note code runs, and--pdfis refused — the command prints why, as the menu's notice does, and exits with1(Trusting a vault);--htmland--latexstill export.
The command is your own, typed by you, so unlike a link it opens a
vault without asking — though a vault new to this device still opens
restricted. It talks to the running Clew over a socket in Clew's
settings folder that only your user account can reach. When Clew is
not running it starts it first, and what you asked for opens in the
window Clew starts with. It prints what it
did — opened Projects/Grant proposal.md in Research, created
Inbox/Call with Sam.md in Research, exported …/Grant
proposal.pdf — and exits with 0 when it did it,
1 when it could not (and says why, e.g. no such file
or folder), and 2 for a command it does not
understand — or an --out with nothing after it — after
printing its usage.
Reference
| Link | Does |
|---|---|
clew://open?vault=V¬e=P#Heading |
Opens note P of vault V at that heading, in a tab of its own |
clew://open?vault=V¬e=P&line=N |
The same, at line N |
clew://open?vault=V |
Brings vault V forward |
clew://new?vault=V&daily=1 |
Today's diary entry, created if missing; a notice says so |
clew://new?vault=V¬e=P |
A new, empty note at P (P 1 if taken); a notice says so |
| Anything else | Refused by name |
| Command | Does |
|---|---|
clew open <file or folder> |
Opens a vault, or a note in its vault |
clew new --daily [--vault V] |
Today's diary entry, created if missing |
clew new <note> [--vault V] |
A new, empty note, never over a file |
clew export --pdf|--latex|--html <note> [--out F] |
Writes only that file (and a .tex's or .html's -figures/ folder) — beside the note, or at F (a file, or a folder that exists or ends in /) — under the vault's trust: in a restricted vault --pdf is refused (exit 1) |
| Exit status | 0 done · 1 failed, with the reason · 2 usage |
| Installed by | Help → Install the clew Command… → /usr/local/bin/clew, else ~/.local/bin/clew; macOS and Linux |
See also
- Navigation, tabs and splits — the tabs a link opens into.
- Daily notes and the diary — what
daily=1and--dailyopen. - Exporting notes — the exports
clew exportruns. - Trusting a vault — what a restricted vault holds back, which no link changes.
- Vaults and files — opening and switching vaults.