7The Dojo is our shell; it processes system commands and returns output. It's a
8good place to quickly experiment with Urbit. On the surface the Dojo is just a
9Hoon REPL. On the inside, the Dojo is a system for operating on and transforming
14You can use the Dojo to run arbitrary Hoon code, as well as non-Hoon system
19Evaluate a Hoon expression (whitespace matters):
22~your-urbit:dojo> (add 2 2)
23~your-urbit:dojo> %+ add 2 2
26Tall-form Hoon may require multiple lines:
29~your-urbit:dojo> %+ add
34Hoon uses something called [the subject](/docs/hoon/hoon-school/the-subject-and-its-legs).
35The Dojo has its own subject and that's where Hoon's equivalent of variables,
36called faces, are stored.
38Use `=var` to save faces to the Dojo subject.
41~your-urbit:dojo> =foo (add 2 2)
44Note, however, that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
45face in a `.hoon` file in this way.
49Use `=dir` to set the current working directory:
52~your-urbit:dojo> =dir %/gen
55(`%` represents your current directory. For a complete explanation on urbit
56paths, see the [filesystem section](#filesystem).)
58Generators (files in `/gen`) are run with `+`:
61~your-urbit:dojo> +hello 'world'
64Save output to a file in `%clay` with `*`:
67~your-urbit:dojo> *some/file/path/hoon 'hello world'
70Run system commands from `:hood`, like `reload`, using `|`:
73~your-urbit:dojo> |reload %eyre
78Generators are short Hoon scripts, saved as `.hoon` files in the `/gen`
79directory. Many Dojo commands exist in the form of generators. The syntax for
80running a generator is `+genname` for a generator saved as `genname.hoon`.
84Accepts a path and displays the file. Similar to Unix `cat`.
87~your-urbit:dojo> +cat %/gen/curl/hoon
92Generates a code that is used to remotely log into your ship. No
96~your-urbit:dojo> +code
99You can change your code to a new randomly generated one by entering `|code
100%reset`. Please note that this will prevent [Bridge](/docs/glossary/bridge)
101from being able to derive your code in the future.
105Retrieves data from a URL. Accepts a `tape`. Similar to Unix `curl`.
108~your-urbit:dojo> +curl "http://nyt.com"
113Just prints the argument. Accepts a `@ta`.
116~your-urbit:dojo> +hello 'mars'
121Similar to Unix `ls`. Accepts a path.
124~your-urbit:dojo> +ls %/gen
125~your-urbit:dojo> +ls /~talsur-todres/home/2/gen/program
130Compile the current state of the kernel and output a
131noun. Usually downloaded to a file in unix. No arguments.
134~your-urbit:dojo> .urbit/pill +solid
139Testrunner. Can test multiple generators at once, conventionally ones
140in the `/test` folder. Takes a path.
143~your-urbit:dojo> +test /lib
148Generate a ticket for an urbit ship. Takes an urbit name (`@p`).
152~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
157Generate a recursive directory listing. Takes a path.
160~your-urbit:dojo> +tree %/sys
165The hood is the system daemon. See `gen/hood` and `app/hood`.
167`|hi` - Sends a direct message. Sort of like Unix `write`. Accepts
168an urbit name (`@p`) and a string (`tape`, which is text wrapped with double-quotes).
171~your-urbit:dojo> |hi ~binzod "you there?"
174`|link` / `|unlink` - Link / unlink a remote app. Accepts an
175Urbit name and an app name.
178~your-urbit:dojo> |link ~talsur-todres %octo
181`|mass` - Prints the current memory usage of all the kernel modules.
185~your-urbit:dojo> |mass
188`|reload` - Reloads a kernel module (vane) from source. Accepts any
192~your-urbit:dojo> |reload %clay %eyre
195`|reset` - Reloads `hoon.hoon` and all modules. No arguments.
198~your-urbit:dojo> |reset
201`|start` - Starts an app. Accepts an app name.
204~your-urbit:dojo> |start %curl
211#### Sources and sinks
213A Dojo command is either a **source** or a **sink**. A source is just something
214that can be printed to your console or the result of some computation. A
215sink is an **effect**: a change to the filesystem, a network message, a
216change to your environment, or a typed message to an app.
218Sources can be chained together, but we can only produce one effect per
223#### `=` - Set variable
225Set any environment variable:
228~your-urbit:dojo> =foo 42
229~your-urbit:dojo> (add 2 foo)
234Make sure to note that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
235variable in a `.hoon` file in this way.
237#### Special variables
239There are a few special variables that the Dojo maintains.
241#### `:` - Send to app
243`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
245Send a `helm-hi` message to `hood`:
248~your-urbit:dojo> :hood &helm-hi 'hi'
251Apps usually expect marked data, so `&` is often used here.
253#### `*` - Save in `%clay`
255Save a new `.hoon` file in `gen`:
258~your-urbit:dojo> *%/gen/foo/hoon '# hello'
261The last component of the path is expected to be the mark (or mime
264#### `.` - Export to Unix
266Export a noun to Unix with `.`:
269~your-urbit:dojo> .foo/bar/baz (add 2 2)
272Which creates a file at `pier/.urb/put/foo/bar.baz`.
274This is very often used with `+solid`:
277~your-urbit:dojo> .urbit/pill +solid
280Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
284#### `_` - Run a function
286Use `_` to run a gate (or function):
288Write an arbitrary function and pass data to it:
291~your-urbit:dojo> _|=([a=@] (mul a 3)) 3
295Use a function to get the status code from an http request:
298~your-urbit:dojo> _|=([p=@ud q=* r=*] p) +http://google.com
302#### `+` `-` - HTTP requests
304`+http[s]://example.com` - sends a GET request
306`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the
307JSON `"hi"` in the body.
309`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the
310JSON `"hi"` in the body.
312Note that the first of these is a source while the last two are sinks.
316Generators are simple Hoon scripts loaded from the filesystem. They live
319An example of a generator that is built into your urbit is `+code`. It produces
320the code needed to log into your ship remotely.
323~your-urbit:dojo> +code
324fintyr-haldet-fassev-solhex
329You can use `=` to set an environment variable in Dojo, but there are
330a few reserved names that have special uses.
334Current working `%clay` desk and revision. Read / write.
339~your-urbit:dojo> =dir %/gen
340~your-urbit:dojo> +ls %
341404/hoon docs/ dojo/hoon lib/ listen/hoon md static/udon talk/ testing/udon tree/main/ unmark/ womb/
346Current set of libraries (`/lib`) in your environment. Can be set
347with `/+`. Read / write.
352~your-urbit:dojo> /+ number-to-words
354Now we can use arms from lib/number-to-words.hoon
356~your-urbit:dojo> (to-words:eng-us:number-to-words 123.456)
361Current set of structures (`/sur`) in your environment. Can be set
362with `/-`. Read / write.
367~your-urbit:dojo> /- sole
369Now we can use arms in sur/sole.hoon.
371~your-urbit:dojo> `sole-effect:sole`[%bel ~]
376The current (128-bit `@da`) time. Read-only.
382~2016.3.21..21.10.57..429a
387The current urbit ship. Read-only.
398512 bits of entropy. Read-only.
404\/0vnt.d474o.gpahj.jcf3o.448fh.2lamb.82ljm.8ol8u.b02vi.mrvvp.b7et2.knb7m.l8he\/
405 8.8qb9s.drm36.77n9b.a0qst.30g03.l5lb5.nvsbc.v39tn
411If you encounter `%dy-edit-busy` while entering commands, it is
412because your Dojo is blocked on a timer or an HTTP request. Type backspace
413and your Dojo will end the blocked command.
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