3template = "page_indiced.html"
7## Shell {#using-the-shell}
9The Dojo is our shell; it processes system commands and returns output. It's a
10good place to quickly experiment with Urbit. On the surface the Dojo is just a
11Hoon REPL. On the inside, the Dojo is a system for operating on and transforming
16You can use the Dojo to run arbitrary Hoon code, as well as non-Hoon system
21Evaluate a Hoon expression (whitespace matters):
24~your-urbit:dojo> (add 2 2)
25~your-urbit:dojo> %+ add 2 2
28Tall-form Hoon may require multiple lines:
31~your-urbit:dojo> %+ add
36Hoon uses something called [the subject](@/docs/hoon/hoon-school/the-subject-and-its-legs.md).
37The Dojo has its own subject and that's where Hoon's equivalent of variables,
38called faces, are stored.
40Use `=var` to save faces to the Dojo subject.
43~your-urbit:dojo> =foo (add 2 2)
46Note, however, that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
47face in a `.hoon` file in this way.
51Use `=dir` to set the current working directory:
54~your-urbit:dojo> =dir %/gen
57(`%` represents your current directory. For a complete explanation on urbit
58paths, see the [filesystem section](#filesystem).)
60Generators (files in `/gen`) are run with `+`:
63~your-urbit:dojo> +hello 'world'
66Save output to a file in `%clay` with `*`:
69~your-urbit:dojo> *some/file/path/hoon 'hello world'
72Run system commands from `:hood`, like `reload`, using `|`:
75~your-urbit:dojo> |reload %eyre
80Generators are short Hoon scripts, saved as `.hoon` files in the `/gen`
81directory. Many Dojo commands exist in the form of generators. The syntax for
82running a generator is `+genname` for a generator saved as `genname.hoon`.
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
102%reset`. Please note that this will prevent [Bridge](@/docs/glossary/bridge.md)
103from being able to derive your code in the future.
107Retrieves data from a URL. Accepts a `tape`. Similar to Unix `curl`.
110~your-urbit:dojo> +curl "http://nyt.com"
115Just prints the argument. Accepts a `@ta`.
118~your-urbit:dojo> +hello 'mars'
123Similar to Unix `ls`. Accepts a path.
126~your-urbit:dojo> +ls %/gen
127~your-urbit:dojo> +ls /~talsur-todres/home/2/gen/program
132Compile the current state of the kernel and output a
133noun. Usually downloaded to a file in unix. No arguments.
136~your-urbit:dojo> .urbit/pill +solid
141Testrunner. Can test multiple generators at once, conventionally ones
142in the `/test` folder. Takes a path.
145~your-urbit:dojo> +test /lib
150Generate a ticket for an urbit ship. Takes an urbit name (`@p`).
154~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
159Generate a recursive directory listing. Takes a path.
162~your-urbit:dojo> +tree %/sys
167The hood is the system daemon. See `gen/hood` and `app/hood`.
169`|hi` - Sends a direct message. Sort of like Unix `write`. Accepts
170an urbit name (`@p`) and a string (`tape`, which is text wrapped with double-quotes).
173~your-urbit:dojo> |hi ~binzod "you there?"
176`|link` / `|unlink` - Link / unlink a remote app. Accepts an
177Urbit name and an app name.
180~your-urbit:dojo> |link ~talsur-todres %octo
183`|mass` - Prints the current memory usage of all the kernel modules.
187~your-urbit:dojo> |mass
190`|reload` - Reloads a kernel module (vane) from source. Accepts any
194~your-urbit:dojo> |reload %clay %eyre
197`|reset` - Reloads `hoon.hoon` and all modules. No arguments.
200~your-urbit:dojo> |reset
203`|start` - Starts an app. Accepts an app name.
206~your-urbit:dojo> |start %curl
213#### Sources and sinks
215A Dojo command is either a **source** or a **sink**. A source is just something
216that can be printed to your console or the result of some computation. A
217sink is an **effect**: a change to the filesystem, a network message, a
218change to your environment, or a typed message to an app.
220Sources can be chained together, but we can only produce one effect per
225#### `=` - Set variable
227Set any environment variable:
230~your-urbit:dojo> =foo 42
231~your-urbit:dojo> (add 2 foo)
236Make sure to note that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
237variable in a `.hoon` file in this way.
239#### Special variables
241There are a few special variables that the Dojo maintains.
243#### `:` - Send to app
245`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
247Send a `helm-hi` message to `hood`:
250~your-urbit:dojo> :hood &helm-hi 'hi'
253Apps usually expect marked data, so `&` is often used here.
255#### `*` - Save in `%clay`
257Save a new `.hoon` file in `gen`:
260~your-urbit:dojo> *%/gen/foo/hoon '# hello'
263The last component of the path is expected to be the mark (or mime
266#### `.` - Export to Unix
268Export a noun to Unix with `.`:
271~your-urbit:dojo> .foo/bar/baz (add 2 2)
274Which creates a file at `pier/.urb/put/foo/bar.baz`.
276This is very often used with `+solid`:
279~your-urbit:dojo> .urbit/pill +solid
282Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
286#### `_` - Run a function
288Use `_` to run a gate (or function):
290Write an arbitrary function and pass data to it:
293~your-urbit:dojo> _|=([a=@] (mul a 3)) 3
297Use a function to get the status code from an http request:
300~your-urbit:dojo> _|=([p=@ud q=* r=*] p) +http://google.com
304#### `+` `-` - HTTP requests
306`+http[s]://example.com` - sends a GET request
308`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the
309JSON `"hi"` in the body.
311`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the
312JSON `"hi"` in the body.
314Note that the first of these is a source while the last two are sinks.
318Generators are simple Hoon scripts loaded from the filesystem. They live
321An example of a generator that is built into your urbit is `+code`. It produces
322the code needed to log into your ship remotely.
325~your-urbit:dojo> +code
326fintyr-haldet-fassev-solhex
331You can use `=` to set an environment variable in Dojo, but there are
332a few reserved names that have special uses.
336Current working `%clay` desk and revision. Read / write.
341~your-urbit:dojo> =dir %/gen
342~your-urbit:dojo> +ls %
343404/hoon docs/ dojo/hoon lib/ listen/hoon md static/udon talk/ testing/udon tree/main/ unmark/ womb/
348Current set of libraries (`/lib`) in your environment. Can be set
349with `/+`. Read / write.
354~your-urbit:dojo> /+ number-to-words
356Now we can use arms from lib/number-to-words.hoon
358~your-urbit:dojo> (to-words:eng-us:number-to-words 123.456)
363Current set of structures (`/sur`) in your environment. Can be set
364with `/-`. Read / write.
369~your-urbit:dojo> /- sole
371Now we can use arms in sur/sole.hoon.
373~your-urbit:dojo> `sole-effect:sole`[%bel ~]
378The current (128-bit `@da`) time. Read-only.
384~2016.3.21..21.10.57..429a
389The current urbit ship. Read-only.
400512 bits of entropy. Read-only.
406\/0vnt.d474o.gpahj.jcf3o.448fh.2lamb.82ljm.8ol8u.b02vi.mrvvp.b7et2.knb7m.l8he\/
407 8.8qb9s.drm36.77n9b.a0qst.30g03.l5lb5.nvsbc.v39tn
413If you encounter `%dy-edit-busy` while entering commands, it is
414because your Dojo is blocked on a timer or an HTTP request. Type backspace
415and 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