5 title/'Filesystem (Clay)'
12Urbit has its own revision-controlled filesystem, Clay. Clay is a typed, global,
13referentially transparent namespace. An easy way to think about it is like typed
14`git` with continuous sync.
16The most common way to use Clay is to mount a Clay node in a Unix directory. The
17Urbit process will watch this directory and automatically record edits as
18changes, Dropbox style. The mounted directory is always at the root of your
24This quick-start guide will walk you through some common commands. Follow along
25using your Dojo. When you get a `>=` message after entering a command, the means
26that the command was successful.
28When developing it's a good idea to use a separate desk. Create a `%sandbox`
29desk based on the `%home` desk:
32|merge %sandbox ~your-urbit %home
35Running `our` produces your ship-name, meaning that you can run the following
36command instead of typing out the entire thing. Useful for comets, due to their
40|merge %sandbox our %home
43Most of the time we want to use Clay from Unix. Mount the entire contents of
44your `sandbox` desk to Unix:
47~your-urbit:dojo> |mount /=sandbox=
50To explore the filesystem from inside Urbit `+ls` and `+cat` are useful. `+ls`
51displays files in the current directory, and `+cat` displays the contents of
54We can use `%` to mean "current directory." The result of the command below
55is just like using `ls` in a Unix terminal.
58~your-urbit:dojo> +ls %
61Notice how `+cat %` does the same thing. That's because everything in Clay,
62including directories, is a file.
64Let's explore the `/web` directory of the `%sandbox` desk.
67~your-urbit:dojo> +ls /=sandbox=/web
70Let's see the contents of `/=sandbox=/web/md`:
73~your-urbit:dojo> +cat /=sandbox=/web/md
76Now let's navigate to that folder using `=dir`, which is a like `cd` in Unix.
79~your-urbit:dojo> =dir /=sandbox=/web/md
82Youl'll notice that your prompt is now `~your-urbit:dojo/sandbox/web/md>`. To
83change back to our home directory, we use `=dir` without any path.
86~your-urbit:dojo/sandbox/web/md> =dir
89Sync from your friend `~some-ship`'s `%experiment` desk to your
93|sync %sandbox ~some-ship %experiment
96If and when your sync is successful, you will receive a message:
99activated sync from %experiment on ~some-ship to %sandbox
102The ship that you sync from will get their own message indicating that you're
103both connected as peers:
106; ~your-urbit is your neighbor.
115A path in Clay is a list of URL-safe text, restricted to the characters
116`[a z]`,`[0 9]`, `.`, `-`, `_`, and `~`. Formally this is a `(list knot)`,
117meaning that each segment, delineated by `/`, is of the `knot` ASCII-text type.
118In other words, paths are expressed as `/foo/bar/baz`. File extensions are
119separated from file names with `/`, not `.`. Extensions are syntactically
120identical to subdirectories, except that they must terminate the path.
122Paths begin with a piece of data called a `beak`. A beak is formally a
123`(p=ship q=desk r=case)`; it has three components, and might look like
124`/~dozbud-namsep/home/11`.
126The first `beak` component is `ship`, which is, as you might guess, the name of
127an Urbit ship. The second component is `desk`, which is a workspace meant to
128contain other directories; the default desk is `%home`. The third component is
129`case`, which represents version information in various ways: date and time;
130a version sequence, which is a value incremented by one whenever a file on the
131given `desk` is modified; or an arbitrary plaintext label.
133You can find what your `beak` is at any given moment by
134typing `%` in the Dojo and looking at the first three results.
136We use `beak`s because, unlike the current internet, the Urbit network uses a
137global namespace. That means that a file named `example.hoon` in the `/gen`
138directory on the `%home` desk of your ship `~lodleb-ritrul` would have a
139universal address to anyone else on the network:
140`~lodleb-ritrul/home/186/gen/example.hoon`. That, of
141course, doesn't mean that everyone on the network has privileges to access that
144The structure that combines a `beak` with further path information is called a
149The `%` command, which we gestured at in the above section, represents the
150*relative path*, which is the path where you are currently working. If your
151working directory is just your home desk, indicated by the
152prompt `~your-planet:dojo>`, then running the command below will print your
153working directory's `beam` information: your `beak`, and a `~` that represents
154the empty list since no path is present.
160`%`s can be stacked to indicate one level further up in the hierarchy for each
161additional `%`. Try the following command:
164~your-planet:dojo> %%%
167You'll probably notice that it only has your ship name and the empty list. The
168two additional `%`s abandoned the `case` and the `desk` information by moving
169up twice the hierarchy.
171There are no local relative paths. `/foo/bar` must be written as
176You don't need to write out the explicit path every time you want to reference
177somewhere outside of your working directory. You can substitute `=` for the
180Recall that a full address in the the Urbit namespace is a `beam`: the
181`/ship/desk/case/path`. If you've switched to another desk before, you're
182already familiar with substitution syntax:
185~your-urbit:dojo> =dir /=sandbox=
188The above command substitutes uses substitution to use your current `ship` and
189`case`; only the `desk` argument, which is located between the other two, is
190given something new. Without substitution, you would need to write:
193~your-urbit:dojo> =dir /~your-urbit/home/85
196Substitutions work the same way in `beak`s (the `ship/desk/case` part) and
197paths. For example, if you are in the `/gen` directory, you can reference a file
198in the `/app` directory like below. (`+cat` displays the contents of a file).
201~your-urbit:dojo/home/gen> +cat /===/app/curl/hoon
204Note what was substituted out, and note that we don't need to separate `=` with
207If we changed our working directory to something called `/gen/gmail`, we could
211~fasdul-balsev-lodleb-ritrul:dojo/home/gen/gmail> +cat /===/app/=/split/hoon
214Because both paths share a directory named `/gmail` at the same position in the
215address hierarchy -- which, if you recall, is just a `list` -- the above command
218We can do the same thing between desks. If `%sandbox` has been merged with
219`%home`, the following command will produce the same results as the above
223~your-urbit:dojo/home/gen/gmail> +cat /=sandbox=/app/=/split/hoon
226Most commonly this is used to avoid having to know the current revision
227number in the `dojo`: `~lodleb-ritrul/home/~2018.10.2..00.35.44..d7e8/gen/example.hoon`
229##### Changing directories
231Change the working directory with `=dir`. It's our equivalent of the Unix `cd`.
233For example, the syntax to navigate to `/home/gen/ask` is:
236~your-urbit:dojo> =dir /=gen=/ask
239This command will turn your prompt into something like this:
242~your-urbit:dojo/gen/ask>
245Using `=dir` without anything else uses the null path, which returns you to
249~your-urbit:dojo> =dir
252To go up levels in the path hierarchy, recall the relative path expression
253`%`. Stacking them represents another level higher in the hierarchy than
254the current working directory for each `%` beyond the initial. The command below
255brings you one level up:
258~your-urbit:dojo/gen> =dir %%
265Syntax: `|mount /clay/path [Unix-name]`
267Mount the `clay-path` at the Unix mount point `Unix-name`.
275Mounts `%/web` to `/web` inside your pier directory.
278|mount %/gen generators
281Mounts `%/gen` to `/generators` inside your pier directory.
286|unmount [clay-path || Unix-name]
289Unmount the path or name from Unix.
297Unmounts the path `%/web` from whatever name it was mounted as.
303Unmounts the Unix path `/generators`.
306|merge desk beak[, =gem strategy]
309Merges a `beak` into a `desk` using an optional merge `strategy`.
311A `beak` is a ship-desk-case triple, encoded as a
312path(`/~dozbud/home/2`)
317|merge %home-work /=home=, =gem %fine
320Merge `/=home=` into `%home-work` using merge strategy `%fine`.
323|merge %examples ~wacbex-ribmex %examples
326Merge the `%examples` desk from `~waxbex-ribmex`
329|sync desk plot [plot-desk]
332Subscribe to continuous updates from remote `plot` on local `desk`.
333`plot-desk` can specify the remote `desk` name. When omitted it is
334defaulted to being the same as `desk`. Non-comet urbits have
335`|sync %home ~parent %kids` automatically set up (where `~parent` is the
336planet that issued a moon, the star that issued a planet, or the galaxy
342|sync %home-local ~dozbud %home
348|unsync desk plot [plot-desk]
351Unsubscribe from updates from remote `plot` on local `desk` with
352optional `plot-desk`. Arguments must match original `|sync` command.
357|unsync %home-local ~dozbud %home
364Label the current version of `desk` `name`.
374`%init` - Used if it's the first commit to a desk. Also can be used to
375"reinitialize" a desk -- revision numbers keep going up, but the new
376revision isn't necessarily a descendent of the previously numbered
377version, allowing merges to be rerun.
379`%this` - Keep what's in Bob's desk, but join the ancestry.
381`%that` - take what's in Alice's desk, but join the ancestry. This is
382the reverse of `%this`. This is different from `%init` because the new
383commit has both sides in its ancestry.
385`%fine` - "fast-forward" merge. This succeeds if and only if one head is in the
386ancestry of the other.
388`%meet`, `%mate`, and `%meld` - find the most recent common ancestor to
389use as our merge base.
391A `%meet` merge only succeeds if the changes from the merge base to
392Alice's head (hereafter, "Alice's changes") are in different files than
393Bob's changes. In this case, the parents are both Alice's and Bob's
394heads, and the data is the merge base plus Alice's changed files plus
397A `%mate` merge attempts to merge changes to the same file when both
398Alice and Bob change it. If the merge is clean, we use it; otherwise, we
399fail. A merge between different types of changes -- for example,
400deleting a file vs changing it -- is always a conflict. If we succeed,
401the parents are both Alice's and Bob's heads, and the data is the merge
402base plus Alice's changed files plus Bob's changed files plus the merged
405A `%meld` merge will succeed even if there are conflicts. If there are
406conflicts in a file, then we use the merge base's version of that file,
407and we produce a set of files with conflicts. The parents are both
408Alice's and Bob's heads, and the data is the merge base plus Alice's
409changed files plus Bob's changed files plus the successfully merged
410files plus the merge base's version of the conflicting files.
412`%auto` - meta-strategy. Check to see if Bob's desk exists, and if it
413doesn't we use an `%init` merge. Otherwise, we progressively try
414`%fine`, `%meet`, and `%mate` until one succeeds. If none succeed, we
415merge Bob's desk into a scratch desk. Then, we merge Alice's desk into
416the scratch desk with the `%meld` option to force the merge. Finally, we
417annotate any conflicts, if we know how.
423Syntax: `+cat path [path ...]`
425Similar to Unix `cat`. `+cat` takes one or more `path`s, and prints their
426contents. If that `path` is a file, the contents of the file is printed. If the
427`path` terminates in a directory, the list of names at that path is produced.
433Similar to Unix `ls`. `+ls` takes a single `path`.
435Produces a list of names at the `path`.
438~your-urbit:dojo> +cat %/our/home/gen/curl/hoon
445Remove the data at `path`. `path` must be a path to actual node, not a
452Copy the file at `from` into the path `to`.
458Move the file at `from` into the path `to`.
460In Clay, `|mv` is just a shorthand for `|cp` then `|rm`. The `|rm`
461doesn't happen unless the `|cp` succeeds.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list