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` in the
81`%base` desk. For generators on other desks, you can use the syntax
86Accepts a path and displays the file. Similar to Unix `cat`.
89~your-urbit:dojo> +cat %/gen/curl/hoon
94Generates a code that is used to remotely log into your ship. No
98~your-urbit:dojo> +code
101You can change your code to a new randomly generated one by entering `|code %reset`. Please note that this will prevent [Bridge](/docs/glossary/bridge)
102from being able to derive your code in the future.
106Similar to Unix `ls`. Accepts a path.
109~your-urbit:dojo> +ls %/gen
110~your-urbit:dojo> +ls /~talsur-todres/base/2/gen/program
115Compile the current state of the kernel and output a noun. Usually downloaded to
116a file in unix. This generator takes a series of desks to include as its
117argument. The first desk must be the base desk that contains the Arvo kernel,
118standard library and related files - typically `%base`.
121~your-urbit:dojo> .urbit/pill +solid %base %garden %landscape %webterm %bitcoin
126Generate a recursive directory listing. Takes a path.
129~your-urbit:dojo> +tree %/sys
134The hood is the system daemon. See `gen/hood` and `app/hood`.
136`|hi` - Sends a direct message. Sort of like Unix `write`. Accepts
137an urbit name (`@p`) and a string (`tape`, which is text wrapped with double-quotes).
140~your-urbit:dojo> |hi ~binzod "you there?"
143`|link` / `|unlink` - Link / unlink a CLI app - may or may not be remote.
144Accepts an optional ship name and a mandatory app name.
147~your-urbit:dojo> |link ~talsur-todres %octo
149~your-urbit:dojo> |link %chat-cli
152`|mass` - Prints the current memory usage of all the kernel modules.
156~your-urbit:dojo> |mass
159`|breload` - Reloads a kernel module (vane) from source. Accepts any
163~your-urbit:dojo> |breload %clay %eyre
170#### Sources and sinks
172A Dojo command is either a **source** or a **sink**. A source is just something
173that can be printed to your console or the result of some computation. A
174sink is an **effect**: a change to the filesystem, a network message, a
175change to your environment, or a typed message to an app.
177Sources can be chained together, but we can only produce one effect per
182#### `=` - Set variable
184Set any environment variable:
187~your-urbit:dojo> =foo 42
188~your-urbit:dojo> (add 2 foo)
193Make sure to note that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
194variable in a `.hoon` file in this way.
196#### Special variables
198There are a few special variables that the Dojo maintains.
200#### `:` - Send to app
202`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
204Send a `helm-hi` message to `hood`:
207~your-urbit:dojo> :hood &helm-hi 'hi'
210Apps usually expect marked data, so `&` is often used here.
212#### `*` - Save in `%clay`
214Save a new `.hoon` file in `gen`:
217~your-urbit:dojo> *%/gen/foo/hoon '# hello'
220The last component of the path is expected to be the mark (or mime
223#### `.` - Export to Unix
225Export a noun to Unix with `.`:
228~your-urbit:dojo> .foo/bar/baz (add 2 2)
231Which creates a file at `pier/.urb/put/foo/bar.baz`.
233This is very often used with `+solid`:
236~your-urbit:dojo> .urbit/pill +solid
239Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
243#### `_` - Run a function
245Use `_` to run a gate (or function):
247Write an arbitrary function and pass data to it:
250~your-urbit:dojo> _|=([a=@] (mul a 3)) 3
254Use a function to get the status code from an http request:
257~your-urbit:dojo> _|=([p=@ud q=* r=*] p) +http://google.com
261#### `+` `-` - HTTP requests
263`+http[s]://example.com` - sends a GET request
265`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the
266JSON `"hi"` in the body.
268`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the
269JSON `"hi"` in the body.
271Note that the first of these is a source while the last two are sinks.
275Generators are simple Hoon scripts loaded from the filesystem. They live
278An example of a generator that is built into your urbit is `+code`. It produces
279the code needed to log into your ship remotely.
282~your-urbit:dojo> +code
283fintyr-haldet-fassev-solhex
286Generators on desks other than `%base` can be run with the syntax
291You can use `=` to set an environment variable in Dojo, but there are
292a few reserved names that have special uses.
296Current working `%clay` desk and revision. Read / write.
301~your-urbit:dojo> =dir %/gen
302~your-urbit:dojo> +ls %
303404/hoon docs/ dojo/hoon lib/ listen/hoon md static/udon talk/ testing/udon tree/main/ unmark/ womb/
308The current (128-bit `@da`) time. Read-only.
314~2016.3.21..21.10.57..429a
319The current urbit ship. Read-only.
330512 bits of entropy. Read-only.
3360v27k.n4atp.fovm6.f7ggm.jdkn5.elct5.11tna.4qtid.g4so7.a1h6g.grp7u.qml4i.0ed1v.sl0r0.97d4b.6aepr.6v6qm.ls5ve.60kgb.j6521.2fqcb
341If you encounter `%dy-edit-busy` while entering commands, it is
342because your Dojo is blocked on a timer or an HTTP request. Type backspace
343and 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