12The `:dojo` is the place to quickly experiment with Urbit. On
13the surface the `:dojo` is just a Hoon REPL. On the inside, the
14`:dojo` is a system for operating on and transforming data in
22Evaluate a hoon expression:
24 ~your-urbit:dojo> (add 2 2)
25 ~your-urbit:dojo> %+ add 2 2
27Tall form Hoon may require multiple lines:
29 ~your-urbit:dojo> %+ add
33Use `=var` to save a shell variable:
35 ~your-urbit:dojo> =foo (add 2 2)
37Use `=dir` to set the current working directory:
39 ~your-urbit:dojo> =dir %/web
41Generators (files in `/gen`) are run with `+`:
43 ~your-urbit:dojo> +hello 'world'
45Save output to a file in `%clay` with `*`:
47 ~your-urbit:dojo> *some/file/path/hoon 'hello world'
49Run system commands from `:hood`, like `reload`, using `|`:
51 ~your-urbit:dojo> |reload %eyre
56**`+cat`** - Similar to Unix `cat`. Accepts a path.
58 ~your-urbit:dojo> +cat %/web/md
59 ~your-urbit:dojo> +cat /~talsur-todres/home/2/web/notes/md
61**`+curl`** - Similar to Unix `curl`. Accepts a `tape`.
63 ~your-urbit:dojo> +curl "http://nyt.com"
65**`+hello`** - Just prints the argument. Accepts a `@ta`.
67 ~your-urbit:dojo> +hello 'mars'
69**`+ls`** - Similar to Unix `ls`. Accepts a path.
71 ~your-urbit:dojo> +ls %/web
72 ~your-urbit:dojo> +ls /~talsur-todres/home/2/web/notes
74**`+moon`** - Generate a random moon from a planet. No arguments.
76**`+solid`** - Compile the current state of the kernel and output a noun. Usually downloaded to a file in unix. No arguments.
78 ~your-urbit:dojo> .urbit/pill +solid
80**`+ticket`** - Generate a ticket for an Urbit plot. Takes an Urbit name (`@p`).
82 ~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
84**`+tree`** - Generate a recursive directory listing. Takes a path.
86 ~your-urbit:dojo> +tree %/web
90The hood is the system daemon. See `gen/hood` and `app/hood`.
92**`|hi`** - Sends a direct message. Sort of like Unix `write`. Accepts an urbit name (`@p`) and a string (`cord`).
94 ~your-urbit:dojo> |hi ~doznec 'you there?'
96**`|link`** / **`|unlink`** - Link / unlink a remote app. Accepts an Urbit name and an app name.
98 ~your-urbit:dojo> |link ~talsur-todres %octo
100**`|mass`** - Prints the current memory usage of all the kernel modules. No arguments.
102**`|reload`** - Reloads a kernel module (vane) from source. Accepts any number of vane names.
104 ~your-urbit:dojo> |reload %clay %eyre
106**`|reset`** - Reloads `hoon.hoon`. No arguments.
108**`|start`** - Starts an app. Accepts an app name.
110 ~your-urbit:dojo> |start %curl
114<h3 class="first child">Sources and sinks</h3>
116A 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.
118Sources can be chained together, but we can only produce one effect per command.
122#### `=` - Set variable
124Set any envronment variable:
126 ~your-urbit:dojo> =foo 42
127 ~your-urbit:dojo> (add 2 foo)
131(There are a few special variables that the dojo expects. See below.)
133#### `:` - Send to app
135`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
137Send a `helm-hi` message to `hood`:
139 ~your-urbit:dojo> :hood &helm-hi 'hi'
141App usually expect marked data, so `&` is often used here.
143#### `*` - Save in `%clay`
145Save a new `md` file in `web`:
147 ~your-urbit:dojo> *%/web/foo/md '# hello'
149The last component of the path is expected to be the mark (or mime type).
151#### `.` - Download to Unix
153Download a noun to Unix with `.`:
155 ~your-urbit:dojo> .foo/bar/baz (add 2 2)
157Which creates a file at `pier/.urb/put/foo/bar.baz`.
159This is very often used with `+solid`:
161 ~your-urbit:dojo> .urbit/pill +solid
163Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
167#### `&` - Mark conversion
169Convert between marks using `&`:
171 ~your-urbit:dojo> &html &md '# hello'
173 '<html><head></head><body><div><h1 id="-hello">hello</h1></div></body></html>'
175#### `_` - Run a function
177Use `_` to run a gate (or function):
179 :: assign an arbitrary function and pass data to it
180 ~your-urbit:dojo> _|=({a/@} (mul a 3)) 3
183 :: assign an arbitrary function to get the status code from an http request
184 ~your-urbit:dojo> _|=({p/@ud q/* r/*} p) +http://google.com
188#### `+` `-` - HTTP requests
190`+http[s]://example.com` - sends a GET request
192`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the JSON `"hi"` in the body.
194`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the JSON `"hi"` in the body.
196Note that the first of these is a source while the last two are
201Generators are simple hoon scripts loaded from the filesystem. They live in `gen/`.
203Create a random moon (from any planet):
205 ~your-urbit:dojo> +moon
207 "moon: ~docsun-tamtem-your-urbit; ticket: ~bartug-hodbyr-fognum-ralmud"
211You can use `=` to set an environment variable in `:dojo`, but there are a few reserved names that have special uses.
215Current working `%clay` desk and revision. Read / write.
219 ~your-urbit:dojo> =dir %/web
220 ~your-urbit:dojo> +ls %
222 404/hoon docs/ dojo/hoon lib/ listen/hoon md static/md talk/ tree/main/
226Current set of libraries (`/lib`) in your environment. Can also be set with `/+`. Read / write.
230 ~your-urbit:dojo> =lib ~[[%react ~]]
231 ~your-urbit:dojo> :: this also works:
232 ~your-urbit:dojo> /+ react
233 ~your-urbit:dojo> :: now we can use arms from lib/react.hoon
234 ~your-urbit:dojo> (react-vale:react %div)
238Current set of structures (`/sur`) in your environment. Can also be set with `/-`. Read / write.
242 ~your-urbit:dojo> =sur ~[[%sole ~]]
243 ~your-urbit:dojo> :: this also works:
244 ~your-urbit:dojo> /- sole
245 ~your-urbit:dojo> :: now we can use arms in sur/sole.hoon
246 ~your-urbit:dojo> `sole-effect:sole`[%bel ~]
250The current (128-bit `@da`) time. Read-only.
254 ~your-urbit:dojo> now
256 ~2016.3.21..21.10.57..429a
260The current urbit plot. Read-only.
264 ~your-urbit:dojo> our
270256 bits of entropy. Read-only.
274 ~your-urbit:dojo> eny
276 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