@@ -1,1413 +0,0 @@
2−title = "Using Your Ship"
3−description = "How to operate your ship, including using your ship's filesystem and messaging applications, starting a moon, or requesting a DNS proxy."
4−template = "page_indiced.html"
6−aliases = ["docs/using/arvo-network-dns/", "docs/using/messaging/", "docs/using/shell/", "docs/using/admin/"]
13−Your urbit (also called your _ship_) is a persistent Unix process that you mainly control from the console.
17−You can turn your urbit off with `Ctrl-d` from the Chat or Dojo prompts.
19−You can force-quit your urbit with `Ctrl-z` from anywhere.
23−To restart your urbit simply pass the name of your pier:
37−To log an urbit's command line output to a file, use `script`:
40−$ script urbit.log ./urbit your-urbit
45−Piers are designed to be portable, but it _must_ be done while the urbit
46−is not running. Urbit networking is stateful, so you can't run two copies
47−of the same urbit in two places.
49−To move a pier, simply move the contents of the directory it lives in.
50−To keep these files as small as possible we usually use the `--sparse`
51−option in `tar`. With a pier `your-urbit/`, something like this should work:
54−tar -Scvzf ~/your-urbit.tar.gz ~/your-urbit/
55−scp your-old-server:~/your-urbit.tar.gz your-new-server:~
58−Then to unzip it, on your other Unix server, run:
61−tar xfvz your-urbit.tar.gz
64−Delete the tar file, and, after installing Urbit on your new server, start your urbit back up with:
72−Your Urbit terminal is separated into two parts: the prompt (the bottom line) and the record (everything above that). The record is shared; all the output from all the apps in your command set appears in it. The prompt is multiplexed.
74−In the CLI, Urbit apps can process your input before you hit return. To see this in action try entering `)` as the first character at the Dojo prompt. Since there is no Dojo command or Hoon expression that starts with ')', the Dojo rejects it.
76−`Ctrl-x` - Switches the prompt between running console apps
78−`Ctrl-c` - Crash current event. Processed at the Unix layer and prints a stack
81−`Ctrl-d` - From Chat or Dojo, stops your Urbit process.
83−`Ctrl-z` - Stops the Urbit process from _anywhere_.
85−`↑` / `↓` - History navigation
87−The following emacs-style key bindings are available:
90−Ctrl-a Cursor to beginning of the line (Home)
91−Ctrl-b Cursor one character backward (left-arrow)
92−Ctrl-e Cursor to the end of the line (End)
93−Ctrl-f Cursor one character forward (right-arrow)
94−Ctrl-g Beep; cancel reverse-search
95−Ctrl-k Kill to end of line
96−Ctrl-l Clear the screen
97−Ctrl-n Next line in history (down-arrow)
98−Ctrl-p Previous line in history (up-arrow)
100−Ctrl-t Transpose characters
101−Ctrl-u Kill to beginning of line
102−Ctrl-y Yank from kill buffer
107−On startup Urbit tries to bind to `localhost:80`. If you're already running something on port `80` -- such as any other HTTP server, or another urbit -- you'll find the urbit that you just started on `8080`, `8081`, and so on. For planets only, we also proxy web domains through Urbit's own servers. Any planet `~your-urbit` is also at `your-urbit.arvo.network`, but only after you [set up DNS](#dns-proxying).
109−Once running, you can sign into Landscape, your ship’s web interface, from `http://localhost` or `https://your-urbit.arvo.network`. Since our HTTPS isn't audited / battle tested, we just call it "secure" HTTPS. You can find that on `8443`. Or `8444` (and so on) if you're already running something on `8443`.
113−Planets can spawn moons, which are meant for connected devices: phones, smart TVs, digital thermostats. The basic idea is that your planet runs permanently in a data center somewhere, while moons run on all your devices. Each planet can issue ~4 billion (`2^32`) moons.
115−To generate a random moon from your planet, run:
118−~sampel-palnet:dojo> |moon
119−moon: ~faswep-navred-sampel-palnet
120−\/0w5cT5t.wCO6i.~e1xg.Oz0qb.QNO6I.3Kt2T.h9M9F.U3vU~.X3Qu0.gtb19.IYTkY.80kWZ.SI\/
121− EUE.DXa8i.TiDof.o3-1C.RHLKS.k81M0.ecz5o.ic0Bg.600g1
125−You must manually edit the output of `|moon` to get the correct format for the `<key>`:
129−- combine into one line, omitting spaces
131−`<key>` would be `0w5cT5t.wCO6i.~e1xg.Oz0qb.QNO6I.3Kt2T.h9M9F.U3vU~.X3Qu0.gtb19.IYTkY.80kWZ.SIEUE.DXa8i.TiDof.o3-1C.RHLKS.k81M0.ecz5o.ic0Bg.600g1`
134−Put `<key>` in a file and that file becomes `<keyfile>`.
136−You can use the resulting output in the same installation flow from the [Installing Urbit](@/using/install.md) guide, following the same scheme as for booting a planet. That scheme is:
139−$ ./urbit -w <moonname> -G <key> -c <piername>
145−$ ./urbit -w <moonname> -k <keyfile> -c <piername>
148−The `-c <piername>` argument is not required, but it is recommended; otherwise,
149−the resulting directory is a rather unwieldy moon name.
151−Here's how an example moon might be booted:
154−$ ./urbit -w faswep-navred-sampel-palnet -G <key> -c mymoon
160−$ ./urbit -w faswep-navred-sampel-palnet -k <keyfile> -c mymoon
163−Moons are automatically synced to their parent `%kids` desk, and can control applications on their parent planet using `|link`.
165−To breach a moon -- that is, to reset its presence on the network so that it's treated as a freshly spawned ship by others -- run from the parent ship:
168−|moon-breach ~faswep-navred-sampel-palnet
171−To cycle the keys of a moon without breaching, run:
174−|moon-cycle-keys ~sampel-sipnym-wicdev-wisryt
178−### Escaping A Sponsor {#escape}
180−To use the network as a planet or star, you must be sponsored by an active star or galaxy, respectively. If your sponsor isn't suiting your needs, you can escape to a different one. The [Bridge](https://bridge.urbit.org/) software doesn't yet support escaping. For the time being, however, you can follow this guide.
184−- A little bit of ETH in your management proxy address to pay for the transaction.
185−- The identity number of the sponsor you want to escape from.
186−- The identity number of the sponsor you want to escape to.
188−You can find an identity's number by running ``` `@`~marzod ``` in any Dojo, where `~marzod` is the name of the relevant identity.
192−0. If you have your management proxy in Metamask, you can use Etherscan [here](https://etherscan.io/address/ecliptic.eth#writeContract). Skip steps 1-4.
193−1. Go to either myetherwallet.com or mycrypto.com. Since this is a low-risk operation, and you're signing with a low-value key, it's fine to use their online versions. Sign in with your management mnemonic. (They may still force you to download their tool to log in like this.)
194−2. Navigate to the "interact with contract" page of the tool you're using.
195−3. Specify a contract address of `0x6ac07B7C4601B5CE11de8Dfe6335B871C7C4dd4d`.
196−4. Copy the "contract ABI" from [here](https://etherscan.io/address/ecliptic.eth#code) and paste it into the "ABI/JSON interface" field.
197−5. Select the `escape()` function, passing in two arguments: your identity number, and the number of your desired sponsor.
198−6. Sign and submit the transaction.
199−7. Get in touch with your prospective sponsor, since they won't be notified otherwise. You can do this by contacting them on the network via chat, or joining `~bitbet-bolbel/urbit-community` and asking around.
200−8. Wait for your request to be accepted by the prospective sponsor.
201−9. If your request is not accepted by your prospective sponsor, a last resort, you can make a request to escape to `~marzod`, which is operated by Tlon, the company leading the development of Urbit.
203−### Continuity breaches
205−While the Urbit network is in this alpha state, we sometimes have to reboot the whole network. This happens either when major changes need to be shipped or we hit a bug that can't be fixed over the air.
207−Because Urbit networking is stateful we call this a _continuity breach_. Everything has to be restarted from scratch. Your pier will continue to function after we have breached, but it won’t connect to the rest of the Urbit network.
209−When this happens, back up any files you'd like to save, shut down your urbit, and recreate it (as if you were starting for the first time).
211−### Life and rift number
213−You can check your ship's _life_ and _rift_ number by running `+keys our` in
214−dojo. You can inspect another ship's life and rift number by running `+keys
215−~sampel-palnet`. For information on what life and rift are, see [Guide to Breaches](@/docs/tutorials/guide-to-breaches.md).
217−## DNS proxying {#dns-proxying}
219−We have a system that lets you request a domain name for your ship in the form of `ship.arvo.network`, where `ship` is your ship's name minus the `~`. This allows users to access their ships remotely using Landscape, our graphical web interface.
221−Stars and planets follow the same process DNS proxying process, and galaxies have their own requirements. Moons and comets are not supported.
223−### Planets and Stars
225−For a planet or star's DNS proxying request to be made and fulfilled, they must be hosting their ship someplace with a public IP address, and its HTTP server must be listening on port 80.
227−To get `ship.arvo.network` on a planet or star, you must set up DNS routing with its parent ship by starting the `:dns` app.
229−To do so, simply run this command in your ship's Dojo, passing the IP address as an argument, using the .0.0.0.0 (`@if`) syntax. For example:
232−> -dns-address &dns-address [%if .1.2.3.4]
235−`:dns`, running locally, will make an HTTP request to that IP address on port 80 to confirm that it is itself available at that IP and port. If that fails, you'll receive a `%bail-early` message in `:chat-cli`; this request will retry a few times. If the self-check is successful, the request is relayed to `~zod`, and you'll receive a message saying, `request for DNS sent to ~zod`. Once `~zod` has acknowledged receipt of the request, your local `:dns` app will send a `:chat-cli` message saying `awaiting response from ~zod`.
237−The request will be picked up shortly, and the `ship.arvo.network` DNS record will be set to the given IP address. Once that's set up, `~zod` will be notified and `~zod` will, in turn, notify your ship. That ship will now try to verify that it can reach itself on `ship.arvo.network` over port 80. If it can't, it'll send a message saying, `unable to access via ship.arvo.network`. If it can, it will configure itself with that domain and say `confirmed access via ship.arvo.network`.
239−Great! You're set up now. Try accessing your `ship.arvo.network` in your browser to use Landscape; we recommend Chrome or Brave.
243−Galaxies are already required to have separate DNS entry at galaxy.urbit.org. There's no automated process for getting that binding, so if you're a galaxy-holder, get in touch with us at support@urbit.org.
245−There is a command for galaxies that will try to re-use their already-necessary Ames DNS entry for HTTPS:
251−This will make HTTP-requests to self-check availability over `galaxy.$AMES-DOMAIN` (currently galaxy.urbit.org), where `galaxy` is the galaxy's name minus the `~`.
253−Otherwise, `-dns-auto` works the same as `:dns|ip` does with stars and planets: if it's available or unavailable, Chat messages, and so on.
257−Configuring a ship's domain causes the `:acme` app to request an HTTPS certificate for that domain from LetsEncrypt. Note that LetsEncrypt also requires that the HTTP server be listening on port 80. If the certificate request fails, `:acme` will send a `:chat-cli` message with an explanation. Once the certificate is successfully retrieved, `:acme` will install it, causing the HTTP servers to restart. A secure server will be started on port 443 (the HTTPS default) if it's available. Otherwise, it will try 8443, and then increment to the next port until it can successfully bind one.
259−The built-in logic for listening on port 80 is similar. Urbit tries to bind port 80; if it cannot, it tries 8080, then increments until it can bind a port. Port 80 is available to unprivileged process on recent version of macOS. Otherwise, the process needs to either be run as root, or be given special permission (CAP\_NET_BIND on Linux).
261−## Messaging {#messaging}
263−Let’s get started using the `:chat-cli` application, also known more simply as _Chat_. It's the simplest way to talk to people using the command line interface.
267−The most common use for `:chat-cli` right now is, of course, communicating in group chats.
271−In `:chat-cli`, any kind of medium for a message is called a _chat_. There are four "types" of chats, but for now we'll be dealing with the _channel_, a publicly accessible chatroom for general use. We'll discuss the other three kinds in the [chat management](#chat-management) section later on.
273−Join the Urbit Community from Dojo using `:group-store|join ~bitbet-bolbel/urbit-community`. Once you've joined, join the General chat from chat-cli. Use `ctrl-x` to switch from the Dojo prompt to the Chat prompt.
278−~sampel-palnet:chat-cli/ ;join ~darrux-landes/general
281−Now that you're in, try post a line to `~darrux-landes/general`:
284−~sampel-palnet:chat-cli= Hello, world!
287−You'll see your message printed below messages from others that came before it. You can always type `;chats` in the `chat-cli` prompt to list all the chats you're in:
290−~sampel-palnet:chat-cli= ;chats
291−~darrux-landes/general
294−Glyphs will be automatically assigned to channels, but have the option of binding a glyph (single non-alphanumeric character) to the channel you're joining; the syntax is in the form of `;join ~/~dopzod/books +`. The chosen glyph will be the symbol that ends your prompt, and it will be what you use as a shortcut to switch to this channel.
297−~sampel-palnet:chat-cli= ;+
298−~sampel-palnet:chat-cli+
301−Use `;leave` to unsubscribe from a channel:
304−~sampel-palnet:chat-cli= ;leave ~darrux-landes/general
307−Now, let's create a channel we can invite some friends to:
310−~sampel-palnet:chat-cli= ;create channel /my-channel
313−Now you can tell your friends to `;join ~your-urbit/my-channel`.
315−In order to see messages in `:chat-cli` you may need to do the following in Dojo:
323−You can use Chat to evaluate Hoon code and share the results with everyone in a chat. To do so, preface your Hoon with `#`.
326−~sampel-palnet:chat-cli= #(add 2 2)
332−~sampel-palnet# (add 2 2)
338−To share a URL, send it as its own message, with no content before or after it.
341−~sampel-palnet:chat-cli= https://urbit.org/
347−~sampel-palnet/ https://urbit.org/
350−### Expanding messages
352−In the case of URLs, they may be too long to display on a single message line. For Hoon code, the code or result could be big. In `:chat-cli`, these get shortened when initially printed out. To view the entire contents, you can select the message in various ways.
355−~sampel-palnet+ some message
357−~sampel-palnet+ let's try selecting this message!
358−~sampel-palnet+ another message
359−~sampel-palnet:chat-cli=
362−In the above example, we can select the middle message by issuing any of the following command:
370−`;n` looks for the last message whose sequence number ends in `n`. `;;` simply picks the second-to-last message.
372−Detailed message output will look something like this:
376− 0v5.g7r7l.n0d7m.mp4bn.gp6vr.sm5lj at ~2019.10.17..22.08.27..8a03
378− to ~dopzod/urbit-help
379−let's try selecting this message!
382−### Creating and managing chats {#chat-management}
384−As mentioned before, any urbit can host any number of chats. Existing chats can be deleted or modified with various commands. All commands in this section should be sent from the `chat-cli>` prompt.
388−Syntax: `;create [type] /name +`, where `+` represents an optional glyph.
390−Creates and joins a chat, where `[type]` is any of the following:
391−- `channel`: public chat. Has a blacklist for write control.
392−- `village`: invite-only chat.
393−- `journal`: publicly readable, invite-only for writing.
394−- `mailbox`: publicly writeable, invite-only for reading.
396−Let's create an example mailbox:
399−~sampel-palnet:chat-cli> ;create mailbox /coolbox ^
404−Syntax: `;delete /name`
408−#### Permission management
410−You can permit and ban people from reading and/or writing to the chats you host, using `;invite` and `;banish` command respectively.
412−Syntax: `;invite [rw] /name ~ships`
414−Where `rw` is either `r`, `w`, or `rw`, representing "read" and "write" permissions.
415−And where `~ships` is a comma-seperated list of ships to invite.
417−For example, to grant two people full access to a `village` we created:
420−~sampel-palnet:chat-cli> ;invite rw /hidden-village ~ravmel-ropdyl, ~rapfyr-diglyt
423−Similarly, if we later want to revoke the writing permissions for one of them, but still allow them to read new messages, we can run:
426−~sampel-palnet:chat-cli> ;banish w /hidden-village ~rapfyr-diglyt
431−Glyphs are found at the end of your prompt, as a quick indicator of where
432−your messages will be sent.
434−Glyphs are assigned by chat hash out of the following list:
437−! @ # $ % ^ & ( ) - = _ + [ ] { } ; ' \ : " , . < > ?
440−Alphanumeric characters and `|#/*~` are reserved; all others can be manually assigned.
442−For example, `-` the glyph at the end of the prompt below might indicates that
443−messages sent from this prompt will go to some chat with that glyph:
446−~sampel-palnet:chat-cli-
449−To see what chat is bound to a glyph, use the `;what` command followed by the
450−glyph in question, or use `;what` without specifying a glyph to see all of your
451−subscriptions which are bound to glyphs. For example, to see `=`:
454−~sampel-palnet:chat-cli> ;what =
458−To see all of your glyph bindings:
461−~sampel-palnet:chat-cli> ;what
462−> ~paldev/numismatic-forum
463−. ~middev/ny-martians
467−When the messaging target doesn't have a glyph, we see their name at the end of
468−the prompt instead. Here we're talking into `~dannum-mitryl/homework`:
471−~sampel-palnet:chat-cli[~dannum-mitryl/homework]
476−Syntax: `;bind [glyph] ~host/chat-name`
478−Assigns the chosen glyph to a chat.
483−~sampel-palnet:chat-cli> ;bind + ~dopzod/urbit-help
488−Syntax: `;unbind [glyph] ~host/chat-name`
490−Unassigns the chosen glyph from a chat owned by your ship.
495−~sampel-palnet:chat-cli> ;unbind + ~dopzod/urbit-help
498−If you don't specify a chat, all bindings for that glyph are removed.
502−Received posts are prefixed with a glyph to let you know what the
503−audience is. You can activate an individual post to see the full
506−There are a few special-purpose "glyphs":
508−- `|` - Informational messages
509−- `*` - Posts to a target you don't have a glyph binding for
518−Set audience to `~ship/chat`.
520−#### Set audience by glyph
524−Set audience to the chat previously bound to the chosen glyph.
526−#### Set audience to own chat
530−Set audience to a chat on your own ship.
532−### Miscellaneous configuration
536−Syntax: `;set timezone [+/-][hours]`
538−Adjust the display of timestamps to a specific timezone. Relative to UTC.
542−Syntax: `;set width [number]`
544−Set the rendering width of `:chat-cli` to a specific number of characters.
549−Syntax: `;set showtime`
551−Show the timestamp for each message. This is set by default.
555−Syntax: `;unset showtime`
557−Stop showing the timestamp for each message.
559−#### Sound notification on
561−Syntax: `;set notify`
563−Emit a terminal bell sound if your six-syllable ship name is mentioned in
564−a message. This is set by default.
566−#### Sound notification off
568−Syntax `;unset notify`
570−Do not notify when your ship name is mentioned.
573−## Shell {#using-the-shell}
575−The Dojo is our shell; it processes system commands and returns output. It's a
576−good place to quickly experiment with Urbit. On the surface the Dojo is just a
577−Hoon REPL. On the inside, the Dojo is a system for operating on and transforming
582−You can use the Dojo to run arbitrary Hoon code, as well as non-Hoon system
587−Evaluate a Hoon expression (whitespace matters):
590−~your-urbit:dojo> (add 2 2)
591−~your-urbit:dojo> %+ add 2 2
594−Tall-form Hoon may require multiple lines:
597−~your-urbit:dojo> %+ add
602−Hoon uses something called [the subject](@/docs/tutorials/hoon/hoon-school/the-subject-and-its-legs.md).
603−The Dojo has its own subject and that's where Hoon's equivalent of variables,
604−called faces, are stored.
606−Use `=var` to save faces to the Dojo subject.
609−~your-urbit:dojo> =foo (add 2 2)
612−Note, however, that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
613−face in a `.hoon` file in this way.
617−Use `=dir` to set the current working directory:
620−~your-urbit:dojo> =dir %/gen
623−(`%` represents your current directory. For a complete explanation on urbit
624−paths, see the [filesystem section](#filesystem).)
626−Generators (files in `/gen`) are run with `+`:
629−~your-urbit:dojo> +hello 'world'
632−Save output to a file in `%clay` with `*`:
635−~your-urbit:dojo> *some/file/path/hoon 'hello world'
638−Run system commands from `:hood`, like `reload`, using `|`:
641−~your-urbit:dojo> |reload %eyre
646−Generators are short Hoon scripts, saved as `.hoon` files in the `/gen`
647−directory. Many Dojo commands exist in the form of generators. The syntax for
648−running a generator is `+genname` for a generator saved as `genname.hoon`.
652−Accepts a path and displays the file. Similar to Unix `cat`.
655−~your-urbit:dojo> +cat %/gen/curl/hoon
660−Generates a code that is used to remotely log into your ship. No
664−~your-urbit:dojo> +code
669−Retrieves data from a URL. Accepts a `tape`. Similar to Unix `curl`.
672−~your-urbit:dojo> +curl "http://nyt.com"
677−Just prints the argument. Accepts a `@ta`.
680−~your-urbit:dojo> +hello 'mars'
685−Similar to Unix `ls`. Accepts a path.
688−~your-urbit:dojo> +ls %/gen
689−~your-urbit:dojo> +ls /~talsur-todres/home/2/gen/program
694−Compile the current state of the kernel and output a
695−noun. Usually downloaded to a file in unix. No arguments.
698−~your-urbit:dojo> .urbit/pill +solid
703−Testrunner. Can test multiple generators at once, conventionally ones
704−in the `/test` folder. Takes a path.
707−~your-urbit:dojo> +test /lib
712−Generate a ticket for an urbit ship. Takes an urbit name (`@p`).
716−~your-urbit:dojo> +ticket ~talsur-todres-your-urbit
721−Generate a recursive directory listing. Takes a path.
724−~your-urbit:dojo> +tree %/sys
729−The hood is the system daemon. See `gen/hood` and `app/hood`.
731−`|hi` - Sends a direct message. Sort of like Unix `write`. Accepts
732−an urbit name (`@p`) and a string (`tape`, which is text wrapped with double-quotes).
735−~your-urbit:dojo> |hi ~binzod "you there?"
738−`|link` / `|unlink` - Link / unlink a remote app. Accepts an
739−Urbit name and an app name.
742−~your-urbit:dojo> |link ~talsur-todres %octo
745−`|mass` - Prints the current memory usage of all the kernel modules.
749−~your-urbit:dojo> |mass
752−`|reload` - Reloads a kernel module (vane) from source. Accepts any
753−number of vane names.
756−~your-urbit:dojo> |reload %clay %eyre
759−`|reset` - Reloads `hoon.hoon` and all modules. No arguments.
762−~your-urbit:dojo> |reset
765−`|start` - Starts an app. Accepts an app name.
768−~your-urbit:dojo> |start %curl
775−#### Sources and sinks
777−A Dojo command is either a **source** or a **sink**. A source is just something
778−that can be printed to your console or the result of some computation. A
779−sink is an **effect**: a change to the filesystem, a network message, a
780−change to your environment, or a typed message to an app.
782−Sources can be chained together, but we can only produce one effect per
787−#### `=` - Set variable
789−Set any environment variable:
792−~your-urbit:dojo> =foo 42
793−~your-urbit:dojo> (add 2 foo)
798−Make sure to note that `=var` is Dojo syntax, not Hoon syntax. You cannot bind a
799−variable in a `.hoon` file in this way.
801−#### Special variables
803−There are a few special variables that the Dojo maintains.
805−#### `:` - Send to app
807−`:app` goes to a local `app`, `:~ship/app` goes to the `app` on `~ship`.
809−Send a `helm-hi` message to `hood`:
812−~your-urbit:dojo> :hood &helm-hi 'hi'
815−Apps usually expect marked data, so `&` is often used here.
817−#### `*` - Save in `%clay`
819−Save a new `.hoon` file in `gen`:
822−~your-urbit:dojo> *%/gen/foo/hoon '# hello'
825−The last component of the path is expected to be the mark (or mime
828−#### `.` - Export to Unix
830−Export a noun to Unix with `.`:
833−~your-urbit:dojo> .foo/bar/baz (add 2 2)
836−Which creates a file at `pier/.urb/put/foo/bar.baz`.
838−This is very often used with `+solid`:
841−~your-urbit:dojo> .urbit/pill +solid
844−Which outputs a new `urbit.pill` to `pier/.urb/put/urbit.pill`
848−#### `_` - Run a function
850−Use `_` to run a gate (or function):
852−Write an arbitrary function and pass data to it:
855−~your-urbit:dojo> _|=([a=@] (mul a 3)) 3
859−Use a function to get the status code from an http request:
862−~your-urbit:dojo> _|=([p=@ud q=* r=*] p) +http://google.com
866−#### `+` `-` - HTTP requests
868−`+http[s]://example.com` - sends a GET request
870−`+http[s]://example.com &json [%s 'hi']` - sends a POST request with the
871−JSON `"hi"` in the body.
873−`-http[s]://example.com &json [%s 'hi']` - sends a PUT request with the
874−JSON `"hi"` in the body.
876−Note that the first of these is a source while the last two are sinks.
878−#### `+` - Generators
880−Generators are simple Hoon scripts loaded from the filesystem. They live
883−An example of a generator that is built into your urbit is `+code`. It produces
884−the code needed to log into your ship remotely.
887−~your-urbit:dojo> +code
888−fintyr-haldet-fassev-solhex
893−You can use `=` to set an environment variable in Dojo, but there are
894−a few reserved names that have special uses.
898−Current working `%clay` desk and revision. Read / write.
903−~your-urbit:dojo> =dir %/gen
904−~your-urbit:dojo> +ls %
905−404/hoon docs/ dojo/hoon lib/ listen/hoon md static/udon talk/ testing/udon tree/main/ unmark/ womb/
910−Current set of libraries (`/lib`) in your environment. Can be set
911−with `/+`. Read / write.
916−~your-urbit:dojo> /+ number-to-words
918−Now we can use arms from lib/number-to-words.hoon
920−~your-urbit:dojo> (to-words:eng-us:number-to-words 123.456)
925−Current set of structures (`/sur`) in your environment. Can be set
926−with `/-`. Read / write.
931−~your-urbit:dojo> /- sole
933−Now we can use arms in sur/sole.hoon.
935−~your-urbit:dojo> `sole-effect:sole`[%bel ~]
940−The current (128-bit `@da`) time. Read-only.
945−~your-urbit:dojo> now
946−~2016.3.21..21.10.57..429a
951−The current urbit ship. Read-only.
956−~your-urbit:dojo> our
962−512 bits of entropy. Read-only.
967−~your-urbit:dojo> eny
968−\/0vnt.d474o.gpahj.jcf3o.448fh.2lamb.82ljm.8ol8u.b02vi.mrvvp.b7et2.knb7m.l8he\/
969− 8.8qb9s.drm36.77n9b.a0qst.30g03.l5lb5.nvsbc.v39tn
975−If you encounter `%dy-edit-busy` while entering commands, it is
976−because your Dojo is blocked on a timer or an HTTP request. Type backspace
977−and your Dojo will end the blocked command.
980−## Filesystem {#filesystem}
982−Urbit has its own revision-controlled filesystem, Clay. Clay is a typed, global,
983−referentially transparent namespace. An easy way to think about it is like typed
986−The most common way to use Clay is to mount a Clay node in a Unix directory. The mounted directory is always at the root of your pier directory.
990−This quick-start guide will walk you through some common commands. Follow along
991−using your Dojo. When you get a `>=` message after entering a command, this means
992−that the command was successful.
994−It's important to note that whenever you want to sync changes from your Unix
995−directory to your ship, you must use the `|commit %desk` command, where `%desk`
996−is the desk that you'd like to sync to.
998−When developing it's a good idea to use a separate desk. Create a `%sandbox`
999−desk based on the `%home` desk:
1002−~your-urbit:dojo> |merge %sandbox ~your-urbit %home
1005−Running `our` produces your ship-name, meaning that you can run the following
1006−command instead of typing out the entire thing. Useful for comets due to their
1010−~your-urbit:dojo> |merge %sandbox our %home
1013−Most of the time we want to use Clay from Unix. Mount the entire contents of
1014−your `sandbox` desk to Unix:
1017−~your-urbit:dojo> |mount /=sandbox=
1020−To explore the filesystem from inside Urbit `+ls` and `+cat` are useful. `+ls`
1021−displays files in the current directory, and `+cat` displays the contents of
1024−We can use `%` to mean "current directory." The result of the command below
1025−is just like using `ls` in a Unix terminal.
1028−~your-urbit:dojo> +ls %
1031−Notice how `+cat %` does the same thing. That's because everything in Clay,
1032−including directories, is a file.
1034−Sync from your friend `~some-ship`'s `%experiment` desk to your
1038−~your-urbit:dojo> |sync %sandbox ~some-ship %experiment
1041−If and when your sync is successful, you will receive a message:
1044−activated sync from %experiment on ~some-ship to %sandbox
1047−The ship that you sync from will get their own message indicating that you're
1048−both connected as peers:
1051−; ~your-urbit is your neighbor.
1060−A path in Clay is a list of URL-safe text, restricted to the characters
1061−`[a z]`,`[0 9]`, `.`, `-`, `_`, and `~`. Formally this is a `(list knot)`,
1062−meaning that each segment, delineated by `/`, is of the `knot` ASCII-text type.
1063−In other words, paths are expressed as `/foo/bar/baz`. File extensions are
1064−separated from file names with `/`, not `.`. Extensions are syntactically
1065−identical to subdirectories, except that they must terminate the path.
1067−Paths begin with a piece of data called a `beak`. A beak is formally a
1068−`(p=ship q=desk r=case)`; it has three components, and might look like
1069−`/~dozbud-namsep/home/11`.
1071−The first `beak` component is `ship`, which is, as you might guess, the name of
1072−an Urbit ship. The second component is `desk`, which is a workspace meant to
1073−contain other directories; the default desk is `%home`. The third component is
1074−`case`, which represents version information in various ways: date and time;
1075−a version sequence, which is a value incremented by one whenever a file on the
1076−given `desk` is modified; or an arbitrary plaintext label.
1078−You can find what your `beak` is at any given moment by
1079−typing `%` in the Dojo and looking at the first three results.
1081−We use `beak`s because, unlike the current internet, the Urbit network uses a
1082−global namespace. That means that a file named `example.hoon` in the `/gen`
1083−directory on the `%home` desk of your ship `~lodleb-ritrul` would have a
1084−universal address to anyone else on the network:
1085−`/~lodleb-ritrul/home/186/gen/example/hoon`. That, of
1086−course, doesn't mean that everyone on the network has privileges to access that
1089−The structure that combines a `beak` with further path information is called a
1094−The `%` command, which we gestured at in the above section, represents the
1095−**relative path**, which is the path where you are currently working. If your
1096−working directory is just your home desk, indicated by the
1097−prompt `~your-planet:dojo>`, then running the command below will print your
1098−working directory's `beam` information: your `beak`, and a `~` that represents
1099−the empty list since no path is present.
1105−`%`s can be stacked to indicate one level further up in the hierarchy for each
1106−additional `%`. Try the following command:
1109−~your-planet:dojo> %%%
1112−You'll probably notice that it only has your ship name and the empty list. The
1113−two additional `%`s abandoned the `case` and the `desk` information by moving
1114−up twice the hierarchy.
1116−There are no local relative paths. `/foo/bar` must be written as
1121−You don't need to write out the explicit path every time you want to reference
1122−somewhere outside of your working directory. You can substitute `=` for the
1125−Recall that a full address in the the Urbit namespace is a `beam`: the
1126−`/ship/desk/case/path`. If you've switched to another desk before, you're
1127−already familiar with substitution syntax:
1130−~your-urbit:dojo> =dir /=sandbox=
1133−The above command uses substitution to use your current `ship` and
1134−`case`; only the `desk` argument, which is located between the other two, is
1135−given something new. Without substitution, you would need to write:
1138−~your-urbit:dojo> =dir /~your-urbit/sandbox/85
1141−Substitutions work the same way in `beak`s (the `ship/desk/case` part) and
1142−paths. For example, if you are in the `/gen` directory, you can reference a file
1143−in the `/app` directory like below. (`+cat` displays the contents of a file).
1146−~your-urbit:dojo> =dir %/gen
1147−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen> +cat /===/app/curl/hoon
1150−Note what was substituted out, and note that we don't need to separate `=` with
1153−If we changed our working directory to something called `/gen/gmail`, we could
1154−access a file called
1157−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen> =dir %/gmail
1158−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen/gmail> +cat /===/app/=/split/hoon
1161−Because both paths share a directory named `/gmail` at the same position in the
1162−address hierarchy – which, if you recall, is just a `list` – the above command
1165−We can do the same thing between desks. If `%sandbox` has been merged with
1166−`%home`, the following command will produce the same results as the above
1170−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen/gmail> +cat /=sandbox=/app/=/split/hoon
1173−Most commonly this is used to avoid having to know the current revision
1174−number in the `dojo`: `/~lodleb-ritrul/home/~2018.10.2..00.35.44..d7e8/gen/example/hoon`
1176−#### Changing directories
1178−Change the working directory with `=dir`. It's our equivalent of the Unix `cd`.
1180−For example, the syntax to navigate to `/home/gen/ask` is:
1183−~your-urbit:dojo> =dir /=home=/gen/ask
1186−This command will turn your prompt into something like this:
1189−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen/ask>
1192−Using `=dir` without anything else uses the null path, which returns you to
1196−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen/ask> =dir
1199−Your dojo prompt will turn back into `~your-urbit:dojo>`.
1201−To go up levels in the path hierarchy, recall the relative path expression
1202−`%`. Stacking them represents another level higher in the hierarchy than
1203−the current working directory for each `%` beyond the initial. The command below
1204−brings you one level up:
1207−~your-urbit:dojo> =dir %/gen
1208−~your-urbit:dojo/=/=/~2018.10.2..00.35.44..d7e8/gen> =dir %%
1211−### Revision-control
1215−Syntax: `|mount /clay/path [Unix-name]`
1217−Mount the `clay-path` at the Unix mount point `Unix-name`.
1222−|mount %/gen generators
1225−Mounts `%/gen` to `/generators` inside your pier directory.
1230−|unmount [clay-path || Unix-name]
1233−Unmount the path or name from Unix.
1241−Unmounts the Clay path `%/gen` from whatever name it was mounted as.
1244−|unmount %generators
1247−Unmounts the Unix path `/generators`.
1252−|merge desk beak[, =gem strategy]
1255−Merges a `beak` into a `desk` using an optional merge `strategy`.
1257−A `beak` is a ship-desk-case triple, encoded as a
1258−path(`/~dozbud/home/2`)
1263−|merge %home-work /=home=, =gem %fine
1266−Merge `/=home=` into `%home-work` using merge strategy `%fine`.
1269−|merge %examples ~wacbex-ribmex %examples
1272−Merge the `%examples` desk from `~waxbex-ribmex`
1277−|sync desk plot [plot-desk]
1280−Subscribe to continuous updates from remote `plot` on local `desk`.
1281−`plot-desk` can specify the remote `desk` name. When omitted it defaults
1282−to being the same as `desk`. Non-comet urbits have
1283−`|sync %home ~parent %kids` automatically set up (where `~parent` is the
1284−planet that issued a moon, the star that issued a planet, or the galaxy
1285−that issued a star).
1290−|sync %home-local ~dozbud %home
1298−|unsync desk plot [plot-desk]
1301−Unsubscribe from updates from remote `plot` on local `desk` with
1302−optional `plot-desk`. Arguments must match original `|sync` command.
1307−|unsync %home-local ~dozbud %home
1316−Label the current version of `desk` `name`.
1321−|label %home release
1324−### Merge strategies
1326−`%init` - used if it's the first commit to a desk. Also can be used to
1327−"reinitialize" a desk – revision numbers keep going up, but the new
1328−revision isn't necessarily a descendent of the previously numbered
1329−version, allowing merges to be rerun.
1331−`%this` - keep what's in Bob's desk, but join the ancestry.
1333−`%that` - take what's in Alice's desk, but join the ancestry. This is
1334−the reverse of `%this`. This is different from `%init` because the new
1335−commit has both sides in its ancestry.
1337−`%fine` - "fast-forward" merge. This succeeds if and only if one head is in the
1338−ancestry of the other.
1340−`%meet`, `%mate`, and `%meld` - find the most recent common ancestor to
1341−use as our merge base.
1343−A `%meet` merge only succeeds if the changes from the merge base to
1344−Alice's head (hereafter, "Alice's changes") are in different files than
1345−Bob's changes. In this case, the parents are both Alice's and Bob's
1346−heads, and the data is the merge base plus Alice's changed files plus
1347−Bob's changed files.
1349−A `%mate` merge attempts to merge changes to the same file when both
1350−Alice and Bob change it. If the merge is clean, we use it; otherwise, we
1351−fail. A merge between different types of changes – for example,
1352−deleting a file vs changing it – is always a conflict. If we succeed,
1353−the parents are both Alice's and Bob's heads, and the data is the merge
1354−base plus Alice's changed files plus Bob's changed files plus the merged
1357−A `%meld` merge will succeed even if there are conflicts. If there are
1358−conflicts in a file, then we use the merge base's version of that file,
1359−and we produce a set of files with conflicts. The parents are both
1360−Alice's and Bob's heads, and the data is the merge base plus Alice's
1361−changed files plus Bob's changed files plus the successfully merged
1362−files plus the merge base's version of the conflicting files.
1364−`%auto` - meta-strategy. Check to see if Bob's desk exists, and if it
1365−doesn't we use an `%init` merge. Otherwise, we progressively try
1366−`%fine`, `%meet`, and `%mate` until one succeeds. If none succeed, we
1367−merge Bob's desk into a scratch desk. Then, we merge Alice's desk into
1368−the scratch desk with the `%meld` option to force the merge. Finally, we
1369−annotate any conflicts, if we know how.
1375−Syntax: `+cat path [path ...]`
1377−Similar to Unix `cat`. `+cat` takes one or more `path`s, and prints their
1378−contents. If that `path` is a file, the contents of the file is printed. If the
1379−`path` terminates in a directory, the list of names at that path is produced.
1385−Similar to Unix `ls`. `+ls` takes a single `path`.
1387−Produces a list of names at the `path`.
1390−~your-urbit:dojo> +cat %/our/home/gen/curl/hoon
1397−Remove the data at `path`. `Path` must be a path to the actual node, not a
1402−Syntax: `|cp to from`
1404−Copy the file at `from` into the path `to`.
1408−Syntax: `|mv to from`
1410−Move the file at `from` into the path `to`.
1412−In Clay, `|mv` is just a shorthand for `|cp` then `|rm`. The `|rm`
1413−doesn't happen unless the `|cp` succeeds.