5 title/'Introduction to the Filesystem'
9# Introduction to the Filesystem
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
23This quick-start guide will walk you through some common commands. Follow along
24using your Dojo. When you get a `>=` message after entering a command, the means
25that the command was successful.
27When developing it's a good idea to use a separate desk. Create a `%sandbox`
28desk based on the `%home` desk:
31|merge %sandbox ~your-urbit %home
34Running `our` produces your ship-name, meaning that you can run the following
35command instead of typing out the entire thing. Useful for comets, due to their
39|merge %sandbox our %home
42Most of the time we want to use Clay from Unix. Mount the entire contents of
43your `sandbox` desk to Unix:
46~your-urbit:dojo> |mount /=sandbox=
49To explore the filesystem from inside Urbit `+ls` and `+cat` are useful. `+ls`
50displays files in the current directory, and `+cat` displays the contents of
53We can use `%` to mean "current directory." The result of the command below
54is just like using `ls` in a Unix terminal.
57~your-urbit:dojo> +ls %
60Notice how `+cat %` does the same thing. That's because everything in Clay,
61including directories, is a file.
63Let's explore the `/web` directory of the `%sandbox` desk.
66~your-urbit:dojo> +ls /=sandbox=/web
69Let's see the contents of `/=sandbox=/web/md`:
72~your-urbit:dojo> +cat /=sandbox=/web/md
75Now let's navigate to that folder using `=dir`, which is a like `cd` in Unix.
78~your-urbit:dojo> =dir /=sandbox=/web/md
81Youl'll notice that your prompt is now `~your-urbit:dojo/sandbox/web/md>`. To
82change back to our home directory, we use `=dir` without any path.
85~your-urbit:dojo/sandbox/web/md> =dir
88Sync from your friend `~some-ship`'s `%experiment` desk to your
92|sync %sandbox ~some-ship %experiment
95If and when your sync is successful, you will receive a message:
98activated sync from %experiment on ~some-ship to %sandbox
101The ship that you sync from will get their own message indicating that you're
102both connected as peers:
105; ~your-urbit is your neighbor.
114A path in Clay is a list of URL-safe text, restricted to the characters
115`[a z]`,`[0 9]`, `.`, `-`, `_`, and `~`. Formally this is a `(list knot)`,
116meaning that each segment, delineated by `/`, is of the `knot` ASCII-text type.
117In other words, paths are expressed as `/foo/bar/baz`. File extensions are
118separated from file names with `/`, not `.`. Extensions are syntactically
119identical to subdirectories, except that they must terminate the path.
121Paths begin with a piece of data called a `beak`. A beak is formally a
122`(p=ship q=desk r=case)`; it has three components, and might look like
123`/~dozbud-namsep/home/11`.
125The first `beak` component is `ship`, which is, as you might guess, the name of
126an Urbit ship. The second component is `desk`, which is a workspace meant to
127contain other directories; the default desk is `%home`. The third component is
128`case`, which represents version information in various ways: date and time;
129a version sequence, which is a value incremented by one whenever a file on the
130given `desk` is modified; or an arbitrary plaintext label.
132You can find what your `beak` is at any given moment by
133typing `%` in the Dojo and looking at the first three results.
135We use `beak`s because, unlike the current internet, the Urbit network uses a
136global namespace. That means that a file named `example.hoon` in the `/gen`
137directory on the `%home` desk of your ship `~lodleb-ritrul` would have a
138universal address to anyone else on the network:
139`~lodleb-ritrul/home/186/gen/example.hoon`. That, of
140course, doesn't mean that everyone on the network has privileges to access that
143The structure that combines a `beak` with further path information is called a
148The `%` command, which we gestured at in the above section, represents the
149*relative path*, which is the path where you are currently working. If your
150working directory is just your home desk, indicated by the
151prompt `~your-planet:dojo>`, then running the command below will print your
152working directory's `beam` information: your `beak`, and a `~` that represents
153the empty list since no path is present.
159`%`s can be stacked to indicate one level further up in the hierarchy for each
160additional `%`. Try the following command:
163~your-planet:dojo> %%%
166You'll probably notice that it only has your ship name and the empty list. The
167two additional `%`s abandoned the `case` and the `desk` information by moving
168up twice the hierarchy.
170There are no local relative paths. `/foo/bar` must be written as
175You don't need to write out the explicit path every time you want to reference
176somewhere outside of your working directory. You can substitute `=` for the
179Recall that a full address in the the Urbit namespace is a `beam`: the
180`/ship/desk/case/path`. If you've switched to another desk before, you're
181already familiar with substitution syntax:
184~your-urbit:dojo> =dir /=sandbox=
187The above command substitutes uses substitution to use your current `ship` and
188`case`; only the `desk` argument, which is located between the other two, is
189given something new. Without substitution, you would need to write:
192~your-urbit:dojo> =dir /~your-urbit/home/85
195Substitutions work the same way in `beak`s (the `ship/desk/case` part) and
196paths. For example, if you are in the `/gen` directory, you can reference a file
197in the `/app` directory like below. (`+cat` displays the contents of a file).
200~your-urbit:dojo/home/gen> +cat /===/app/curl/hoon
203Note what was substituted out, and note that we don't need to separate `=` with
206If we changed our working directory to something called `/gen/gmail`, we could
210~fasdul-balsev-lodleb-ritrul:dojo/home/gen/gmail> +cat /===/app/=/split/hoon
213Because both paths share a directory named `/gmail` at the same position in the
214address hierarchy -- which, if you recall, is just a `list` -- the above command
217We can do the same thing between desks. If `%sandbox` has been merged with
218`%home`, the following command will produce the same results as the above
222~your-urbit:dojo/home/gen/gmail> +cat /=sandbox=/app/=/split/hoon
225Most commonly this is used to avoid having to know the current revision
226number in the `dojo`: `~lodleb-ritrul/home/~2018.10.2..00.35.44..d7e8/gen/example.hoon`
228##### Changing directories
230Change the working directory with `=dir`. It's our equivalent of the Unix `cd`.
232For example, the syntax to navigate to `/home/gen/ask` is:
235~your-urbit:dojo> =dir /=gen=/ask
238This command will turn your prompt into something like this:
241~your-urbit:dojo/gen/ask>
244Using `=dir` without anything else uses the null path, which returns you to
248~your-urbit:dojo> =dir
251To go up levels in the path hierarchy, recall the relative path expression
252`%`. Stacking them represents another level higher in the hierarchy than
253the current working directory for each `%` beyond the initial. The command below
254brings you one level up:
257~your-urbit:dojo/gen> =dir %%
264Syntax: `|mount /clay/path [Unix-name]`
266Mount the `clay-path` at the Unix mount point `Unix-name`.
274Mounts `%/web` to `/web` inside your pier directory.
277|mount %/gen generators
280Mounts `%/gen` to `/generators` inside your pier directory.
285|unmount [clay-path || Unix-name]
288Unmount the path or name from Unix.
296Unmounts the path `%/web` from whatever name it was mounted as.
302Unmounts the Unix path `/generators`.
305|merge desk beak[, =gem strategy]
308Merges a `beak` into a `desk` using an optional merge `strategy`.
310A `beak` is a ship-desk-case triple, encoded as a
311path(`/~dozbud/home/2`)
316|merge %home-work /=home=, =gem %fine
319Merge `/=home=` into `%home-work` using merge strategy `%fine`.
322|merge %examples ~wacbex-ribmex %examples
325Merge the `%examples` desk from `~waxbex-ribmex`
328|sync desk plot [plot-desk]
331Subscribe to continuous updates from remote `plot` on local `desk`.
332`plot-desk` can specify the remote `desk` name. When omitted it is
333defaulted to being the same as `desk`. Non-comet urbits have
334`|sync %home ~parent %kids` automatically set up (where `~parent` is the
335planet that issued a moon, the star that issued a planet, or the galaxy
341|sync %home-local ~dozbud %home
347|unsync desk plot [plot-desk]
350Unsubscribe from updates from remote `plot` on local `desk` with
351optional `plot-desk`. Arguments must match original `|sync` command.
356|unsync %home-local ~dozbud %home
363Label the current version of `desk` `name`.
373`%init` - Used if it's the first commit to a desk. Also can be used to
374"reinitialize" a desk -- revision numbers keep going up, but the new
375revision isn't necessarily a descendent of the previously numbered
376version, allowing merges to be rerun.
378`%this` - Keep what's in Bob's desk, but join the ancestry.
380`%that` - take what's in Alice's desk, but join the ancestry. This is
381the reverse of `%this`. This is different from `%init` because the new
382commit has both sides in its ancestry.
384`%fine` - "fast-forward" merge. This succeeds if and only if one head is in the
385ancestry of the other.
387`%meet`, `%mate`, and `%meld` - find the most recent common ancestor to
388use as our merge base.
390A `%meet` merge only succeeds if the changes from the merge base to
391Alice's head (hereafter, "Alice's changes") are in different files than
392Bob's changes. In this case, the parents are both Alice's and Bob's
393heads, and the data is the merge base plus Alice's changed files plus
396A `%mate` merge attempts to merge changes to the same file when both
397Alice and Bob change it. If the merge is clean, we use it; otherwise, we
398fail. A merge between different types of changes -- for example,
399deleting a file vs changing it -- is always a conflict. If we succeed,
400the parents are both Alice's and Bob's heads, and the data is the merge
401base plus Alice's changed files plus Bob's changed files plus the merged
404A `%meld` merge will succeed even if there are conflicts. If there are
405conflicts in a file, then we use the merge base's version of that file,
406and we produce a set of files with conflicts. The parents are both
407Alice's and Bob's heads, and the data is the merge base plus Alice's
408changed files plus Bob's changed files plus the successfully merged
409files plus the merge base's version of the conflicting files.
411`%auto` - meta-strategy. Check to see if Bob's desk exists, and if it
412doesn't we use an `%init` merge. Otherwise, we progressively try
413`%fine`, `%meet`, and `%mate` until one succeeds. If none succeed, we
414merge Bob's desk into a scratch desk. Then, we merge Alice's desk into
415the scratch desk with the `%meld` option to force the merge. Finally, we
416annotate any conflicts, if we know how.
422Syntax: `+cat path [path ...]`
424Similar to Unix `cat`. `+cat` takes one or more `path`s, and prints their
425contents. If that `path` is a file, the contents of the file is printed. If the
426`path` terminates in a directory, the list of names at that path is produced.
432Similar to Unix `ls`. `+ls` takes a single `path`.
434Produces a list of names at the `path`.
437~your-urbit:dojo> +cat %/our/home/gen/curl/hoon
444Remove the data at `path`. `path` must be a path to actual node, not a
451Copy the file at `from` into the path `to`.
457Move the file at `from` into the path `to`.
459In Clay, `|mv` is just a shorthand for `|cp` then `|rm`. The `|rm`
460doesn'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