12The `:dojo` is the place to quickly experiment with Urbit. At first glance the `:dojo` is just a Hoon REPL. Looking a bit deeper the `:dojo` is set up to make operating on and transforming data in Urbit easy.
19Evaluate a hoon expression:
21 ~your-urbit:dojo> (add 2 2)
22 ~your-urbit:dojo> %+ add 2 2
24Tall form Hoon will be prompted for:
26 ~your-urbit:dojo> %+ add
30Use `=var` to save a shell variable:
32 ~your-urbit:dojo> =foo (add 2 2)
34Use `=dir` to set the current working directory:
36 ~your-urbit:dojo> =dir %/web
38Generators (files in `/gen`) are run with `+`:
40 ~your-urbit:dojo> +hello 'world'
42Save output to a file in `%clay` with `*`:
44 ~your-urbit:dojo> *some/file/path/hoon 'hello world'
46Run system commands from `:hood`, like `reload`, using `|`:
48 ~your-urbit:dojo> |reload %eyre
52<h3 class="first child">Sources and sinks</h3>
54A 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.
56Sources can be chained together, but we can only produce one effect per command.
60#### `=` - Set variable
62Set any envronment variable:
64 ~your-urbit:dojo> =foo 42
65 ~your-urbit:dojo> (add 2 foo)
69(There are a few special variables that the dojo expects. See below.)
73`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
75Send a `helm-hi` message to `hood`:
77 ~your-urbit:dojo> :hood &helm-hi 'hi'
79App usually expect marked data, so `&` is often used here.
81#### `*` - Save in `%clay`
83Save a new `md` file in `web`:
85 ~your-urbit:dojo> *%/web/foo/md '# hello'
87The last component of the path is expected to be the mark (or mime type).
89#### `.` - Download to Unix
91Download a noun to Unix with `.`:
93 ~your-urbit:dojo> .foo/bar/baz (add 2 2)
95Which creates a file at `pier/.urb/put/foo/bar.baz`.
97This is very often used with `+solid`:
99 ~your-urbit:dojo> .urbit/pill +solid
101Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
105#### `&` - Mark conversion
107Convert between marks using `&`:
109 ~your-urbit:dojo> &html &md '# hello'
111 '<html><head></head><body><div><h1 id="-hello">hello</h1></div></body></html>'
113#### `_` - Run a function
115Use `_` to run a gate (or function):
117 :: assign an arbitrary function and pass data to it
118 ~your-urbit:dojo> _|=({a/@} (mul a 3)) 3
121 :: assign an arbitrary function to get the status code from an http request
122 ~your-urbit:dojo> _|=({p/@ud q/* r/*} p) +http://google.com
126#### `+` `-` - HTTP requests
128`+http[s]://example.com` - sends a GET request
130`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the JSON `"hi"` in the body.
132`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the JSON `"hi"` in the body.
136Generators are simple hoon scripts loaded from the filesystem. They live in `gen/`.
138Create a random moon (from any planet):
140 ~your-urbit:dojo> +moon
142 "moon: ~docsun-tamtem-your-urbit; ticket: ~bartug-hodbyr-fognum-ralmud"
146You can use `=` to set an environment variable in `:dojo`, but there are a few reserved names that have special uses.
150Current working `%clay` desk and revision. Read / write.
154 ~your-urbit:dojo> =dir %/web
155 ~your-urbit:dojo> +ls %
157 404/hoon docs/ dojo/hoon lib/ listen/hoon md static/md talk/ tree/main/
161Current set of libraries (`/lib`) in your environment. Can also be set with `/+`. Read / write.
165 ~your-urbit:dojo> =lib ~[[%react ~]]
166 ~your-urbit:dojo> :: this also works:
167 ~your-urbit:dojo> /+ react
168 ~your-urbit:dojo> :: now we can use arms from lib/react.hoon
169 ~your-urbit:dojo> (react-vale:react %div)
173Current set of structures (`/sur`) in your environment. Can also be set with `/-`. Read / write.
177 ~your-urbit:dojo> =sur ~[[%sole ~]]
178 ~your-urbit:dojo> :: this also works:
179 ~your-urbit:dojo> /- sole
180 ~your-urbit:dojo> :: now we can use arms in sur/sole.hoon
181 ~your-urbit:dojo> `sole-effect:sole`[%bel ~]
185The current (128-bit `@da`) time. Read-only.
189 ~your-urbit:dojo> now
191 ~2016.3.21..21.10.57..429a
195The current urbit plot. Read-only.
199 ~your-urbit:dojo> our
205256 bits of entropy. Read-only.
209 ~your-urbit:dojo> eny
211 0v1o.m2vio.j5ieb.7tq84.5kcnp.gjn04.9gl2e.tkj5v.0oqk3.iugk8.rhu6o
215**`+cat`** - Similar to Unix `cat`. Accepts a path.
217 ~your-urbit:dojo> +cat %/web/md
218 ~your-urbit:dojo> +cat /~talsur-todres/home/2/web/notes/md
220**`+curl`** - Similar to Unix `curl`. Accepts a `tape`.
222 ~your-urbit:dojo> +curl "http://nyt.com"
224**`+hello`** - Just prints the argument. Accepts a `@ta`.
226 ~your-urbit:dojo> +hello 'mars'
228**`+ls`** - Similar to Unix `ls`. Accepts a path.
230 ~your-urbit:dojo> +ls %/web
231 ~your-urbit:dojo> +ls /~talsur-todres/home/2/web/notes
233**`+moon`** - Generate a random moon from a planet. No arguments.
235**`+solid`** - Compile the current state of the kernel and output a noun. Usually downloaded to a file in unix. No arguments.
237 ~your-urbit:dojo> .urbit/pill +solid
239**`+ticket`** - Generate a ticket for an Urbit plot. Takes an Urbit name (`@p`).
241 ~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
243**`+tree`** - Generate a recursive directory listing. Takes a path.
245 ~your-urbit:dojo> +tree %/web
249The hood is the system daemon. See `gen/hood` and `app/hood`.
251**`|hi`** - Sends a direct message. Sort of like Unix `write`. Accepts an urbit name (`@p`) and a string (`cord`).
253 ~your-urbit:dojo> |hi ~doznec 'you there?'
255**`|link`** / **`|unlink`** - Link / unlink a remote app. Accepts an Urbit name and an app name.
257 ~your-urbit:dojo> |link ~talsur-todres %octo
259**`|mass`** - Prints the current memory usage of all the kernel modules. No arguments.
261**`|reload`** - Reloads a kernel module (vane) from source. Accepts any number of vane names.
263 ~your-urbit:dojo> |reload %clay %eyre
265**`|reset`** - Reloads `hoon.hoon`. No arguments.
267**`|start`** - Starts an app. Accepts an app name.
269 ~your-urbit:dojo> |start %curl
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