13The `:dojo` is the place to quickly experiment with Urbit. On
14the surface the `:dojo` is just a Hoon REPL. On the inside, the
15`:dojo` is a system for operating on and transforming data in
23Evaluate a hoon expression:
25 ~your-urbit:dojo> (add 2 2)
26 ~your-urbit:dojo> %+ add 2 2
28Tall form Hoon may require multiple lines:
30 ~your-urbit:dojo> %+ add
34Use `=var` to save a shell variable:
36 ~your-urbit:dojo> =foo (add 2 2)
38Use `=dir` to set the current working directory:
40 ~your-urbit:dojo> =dir %/web
42Generators (files in `/gen`) are run with `+`:
44 ~your-urbit:dojo> +hello 'world'
46Save output to a file in `%clay` with `*`:
48 ~your-urbit:dojo> *some/file/path/hoon 'hello world'
50Run system commands from `:hood`, like `reload`, using `|`:
52 ~your-urbit:dojo> |reload %eyre
57**`+cat`** - Similar to Unix `cat`. Accepts a path.
59 ~your-urbit:dojo> +cat %/web/md
60 ~your-urbit:dojo> +cat /~talsur-todres/home/2/web/notes/md
62**`+curl`** - Similar to Unix `curl`. Accepts a `tape`.
64 ~your-urbit:dojo> +curl "http://nyt.com"
66**`+hello`** - Just prints the argument. Accepts a `@ta`.
68 ~your-urbit:dojo> +hello 'mars'
70**`+ls`** - Similar to Unix `ls`. Accepts a path.
72 ~your-urbit:dojo> +ls %/web
73 ~your-urbit:dojo> +ls /~talsur-todres/home/2/web/notes
75**`+moon`** - Generate a random moon from a planet. No arguments.
77 ~your-urbit:dojo> +moon
79**`+solid`** - Compile the current state of the kernel and output a noun. Usually downloaded to a file in unix. No arguments.
81 ~your-urbit:dojo> .urbit/pill +solid
83**`+ticket`** - Generate a ticket for an Urbit plot. Takes an Urbit name (`@p`).
85 ~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
87**`+tree`** - Generate a recursive directory listing. Takes a path.
89 ~your-urbit:dojo> +tree %/web
93The hood is the system daemon. See `gen/hood` and `app/hood`.
95**`|hi`** - Sends a direct message. Sort of like Unix `write`. Accepts an urbit name (`@p`) and a string (`cord`).
97 ~your-urbit:dojo> |hi ~doznec 'you there?'
99**`|link`** / **`|unlink`** - Link / unlink a remote app. Accepts an Urbit name and an app name.
101 ~your-urbit:dojo> |link ~talsur-todres %octo
103**`|mass`** - Prints the current memory usage of all the kernel modules. No arguments.
105 ~your-urbit:dojo> |mass
107**`|reload`** - Reloads a kernel module (vane) from source. Accepts any number of vane names.
109 ~your-urbit:dojo> |reload %clay %eyre
111**`|reset`** - Reloads `hoon.hoon` and all modules. No arguments.
113 ~your-urbit:dojo> |reset
115**`|start`** - Starts an app. Accepts an app name.
117 ~your-urbit:dojo> |start %curl
121<h3 class="first child">Sources and sinks</h3>
123A dojo command is either a source or a sink. A source is just something that can be printed to your console or the result of some computation. A sink is an *effect*: a change to the filesystem, a network message, a change to your environment, or typed message to an app.
125Sources can be chained together, but we can only produce one effect per command.
129#### `=` - Set variable
131Set any envronment variable:
133 ~your-urbit:dojo> =foo 42
134 ~your-urbit:dojo> (add 2 foo)
138(There are a few special variables that the dojo maintains. See below.)
140#### `:` - Send to app
142`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
144Send a `helm-hi` message to `hood`:
146 ~your-urbit:dojo> :hood &helm-hi 'hi'
148App usually expect marked data, so `&` is often used here.
150#### `*` - Save in `%clay`
152Save a new `md` file in `web`:
154 ~your-urbit:dojo> *%/web/foo/md '# hello'
156The last component of the path is expected to be the mark (or mime type).
158#### `.` - Export to Unix
160Export a noun to Unix with `.`:
162 ~your-urbit:dojo> .foo/bar/baz (add 2 2)
164Which creates a file at `pier/.urb/put/foo/bar.baz`.
166This is very often used with `+solid`:
168 ~your-urbit:dojo> .urbit/pill +solid
170Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
174#### `&` - Mark conversion
176Convert between marks using `&`:
178 ~your-urbit:dojo> &html &md '# hello'
180 '<html><head></head><body><div><h1 id="-hello">hello</h1></div></body></html>'
182#### `_` - Run a function
184Use `_` to run a gate (or function):
186 :: assign an arbitrary function and pass data to it
187 ~your-urbit:dojo> _|=({a/@} (mul a 3)) 3
190 :: use a function to get the status code from an http request
191 ~your-urbit:dojo> _|=({p/@ud q/* r/*} p) +http://google.com
195#### `+` `-` - HTTP requests
197`+http[s]://example.com` - sends a GET request
199`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the JSON `"hi"` in the body.
201`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the JSON `"hi"` in the body.
203Note that the first of these is a source while the last two are
208Generators are simple hoon scripts loaded from the filesystem. They live in `gen/`.
210Create a random moon (from any planet):
212 ~your-urbit:dojo> +moon
214 "moon: ~docsun-tamtem-your-urbit; ticket: ~bartug-hodbyr-fognum-ralmud"
218You can use `=` to set an environment variable in `:dojo`, but there are a few reserved names that have special uses.
222Current working `%clay` desk and revision. Read / write.
226 ~your-urbit:dojo> =dir %/web
227 ~your-urbit:dojo> +ls %
229 404/hoon docs/ dojo/hoon lib/ listen/hoon md static/md talk/ tree/main/
233Current set of libraries (`/lib`) in your environment. Can also be set with `/+`. Read / write.
237 ~your-urbit:dojo> =lib ~[[%react ~]]
238 ~your-urbit:dojo> :: this also works:
239 ~your-urbit:dojo> /+ react
240 ~your-urbit:dojo> :: now we can use arms from lib/react.hoon
241 ~your-urbit:dojo> (react-vale:react %div)
245Current set of structures (`/sur`) in your environment. Can also be set with `/-`. Read / write.
249 ~your-urbit:dojo> =sur ~[[%sole ~]]
250 ~your-urbit:dojo> :: this also works:
251 ~your-urbit:dojo> /- sole
252 ~your-urbit:dojo> :: now we can use arms in sur/sole.hoon
253 ~your-urbit:dojo> `sole-effect:sole`[%bel ~]
257The current (128-bit `@da`) time. Read-only.
261 ~your-urbit:dojo> now
263 ~2016.3.21..21.10.57..429a
267The current urbit plot. Read-only.
271 ~your-urbit:dojo> our
277256 bits of entropy. Read-only.
281 ~your-urbit:dojo> eny
283 0v1o.m2vio.j5ieb.7tq84.5kcnp.gjn04.9gl2e.tkj5v.0oqk3.iugk8.rhu6o
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