10# Using Urbit from Unix
12With `urb` at your Unix command line, you can execute hoon, run
13dojo commands, and more. Additionally, with `fuse`, you can
14inspect the urbit namespace.
21These commands are in the a [separate
22repo](https://github.com/urbit/urb). Clone this repo to get the
25You'll also need the `requests` and `fuse` libraries for python.
26If you have `pip`, you can just run:
29pip install requests fuse-python
32Otherwise, on Ubuntu, run:
35apt-get install python-requests python-fuse
38Then you can either run the python commands from the git repo, or
39put them somewhere in your path.
43`urb` transfers data from a source to a sink. Examples of data
44sources include literal data, a file, a URL, or some
45tranformation of another source. Examples of data sinks are
46stdout, output file, POST request, or dojo command.
48Here are some examples. This takes the literal data "hello
49world" and sends it to stdout (the default sink).
51 urb --data 'hello world'
53Let's run some hoon code at the dojo.
55 urb --dojo '(add 2 2)'
57Let's convert a markdown file to html.
59 urb --data @@file.md -m md -m html
61Mount the `%home` desk. This syncs the `home` desk into the pier
64 urb --dojo '+hood/mount /=home=' --app hood
68Sources can be any of the following:
70- `-d, --dojo command` runs a dojo command. This is commonly
71 naked hoon code, but it can also be a generator, or any of the
72 other ways the dojo gets data.
74- `-D, --data text` is literal text data, as a cord.
76- `-c, --clay path` pulls data from Urbit's filesystem.
78- `-u, --url url` pulls data from a URL.
80- `-m, --mark mark source` converts the output from another source to
81 a new 'mark' (datatype).
83- `-H, --hoon code source` transforms the output of another
84 source by running it through some hoon code.
86- `[source-0 source-1 ...]`. Sources can be combined into tuples
89Any of the arguments to a source (except in the "compound
90sources" `--mark` and `--hoon`) can be replaced by `-` to
91represent stdin or `@@filename` to pull data in from a Unix file.
92Thus, `urb [-D @@file1 -D - -D @@file2]` is equivalent to Unix's
95Additionally, if no source is specified, `--data -` (stdin as
96literal text data) is assumed.
100- `-s, --stdout` outputs to stdout. This is the default.
102- `-f, --output-file path` writes to a unix file.
104- `-C, --output-clay path` writes to Urbit's filesystem.
106- `-U, --output-url url` sends a POST request with the data to
109- `-p, --app app` sends the data to an urbit app.
111- `-x, --command` outputs to a literal dojo command.
115Urbit's namespace is accessible through the `fuse` command.
116`fuse` takes all the normal FUSE arguments, which you can see
117with `fuse -h`. Generally, you just run `fuse MOUNT-POINT`.
119When accessing the namespace through `fuse`, everything is
120read-only. If you want to write to Clay, mount a desk, as
123Let's look first in the Clay portion of the Urbit namespace.
124Assume we've mounted to `./pt`.
127 app arvo gen lib mar ren sec sur web
128 $ ls ./pt/c/=/=/=/arvo
129 ames behn clay dill eyre ford gall hoon zuse
131Those `=`s aren't decorative. The first `=` means "current
132ship", the second "current desk", and the third "current
133revision". Let's try something a little more exciting.
135This runs the Unix `diff` command on the first and current
136versions of the `app/gh/hoon` file, showing all the changes we've
140$ diff pt/c/=/=/{1,=}/app/gh/hoon
142< (malt (turn issues |=(issue:gh [(rsh 3 2 (scot %ui number)) ~])))
144> %- malt ^- (list {@ta $~})
145> :- [%gh-list-issues ~]
146> (turn issues |=(issue:gh [(rsh 3 2 (scot %ui number)) ~]))
148< read-y=(read-get /issues)
150> read-y=(read-static %gh-list-issues ~)
151> sigh-x=sigh-list-issues-x
152> sigh-y=sigh-list-issues-y
154> ^- place :: /issues/mine/<mark>
155> :* guard={$issues $mine @t $~}
157> read-y=|=(pax/path [ost %diff %arch `0vsen.tinel ~])
159< ^- place :: /issues/by-repo/<user>/<repo>
161> ^- place :: /issues/by-repo/<user>/<repo>/<number>
163< read-y=(read-static ~)
168> ?: ((sane %tas) -.+>+>.pax)
170> (read-static %gh-issue ~)
175> ^- place :: /issues/by-repo/<u>/<r>/<n>/<mark>
176> :* guard={$issues $by-repo @t @t @t @t $~}
178> read-y=|=(pax/path [ost %diff %arch `0vsen.tinel ~])
182Urbit's namespace is not just revisioned, but global. Here's a
183diff of our version of `arvo/gall/hoon` compared to the one on
187$ diff pt/c/{~bud,=}/=/=/arvo/gall/hoon
195> [mar=i tyl=(flop t)]
197< ((slog leaf+"peek find fail" >tyl< ~) [~ ~])
199> ((slog leaf+"peek find fail" >tyl< >mar< ~) [~ ~])
208Besides Clay, the namespace contains Gall apps. One common usage
209of the app namespace is to expose APIs. For example, if you
210start the `%gh` app (`|start %gh`), you can do things like `cat`
211an issue from a repository.
214$ cat pt/g/=/gh/=/issues/by-repo/philipcmonktest/testing/7/txt
217creator: philipcmonktest
218created-at: 2016-03-24T22:27:33Z
219assignee: philipcmonktest
220labels: invalid, wontfix, help wanted
222url: https://api.github.com/repos/philipcmonktest/testing/issues/7
224Yup, that's it. i mean, maybe it's a bit longer than that.
226But you get the point, right?
231Or all open issues for a repository.
234$ cat pt/g/=/gh/=/issues/by-repo/philipcmonktest/testing/txt
235title: i found a bug! (#11)
237creator: philipcmonktest
238created-at: 2016-04-14T23:14:49Z
242url: https://api.github.com/repos/philipcmonktest/testing/issues/11
245----------------------------------------
248creator: philipcmonktest
249created-at: 2016-03-24T22:29:16Z
253url: https://api.github.com/repos/philipcmonktest/testing/issues/8
255Yup, that's it. i mean, maybe it's a bit longer than that.
257But you get the point, right?
260----------------------------------------
263creator: philipcmonktest
264created-at: 2016-03-24T22:27:33Z
265assignee: philipcmonktest
266labels: invalid, wontfix, help wanted
268url: https://api.github.com/repos/philipcmonktest/testing/issues/7
270Yup, that's it. i mean, maybe it's a bit longer than that.
272But you get the point, right?
275----------------------------------------
276title: something different (#4)
278creator: philipcmonktest
279created-at: 2016-01-26T21:45:08Z
280assignee: philipcmonktest
281labels: duplicate, help wanted, question, bug
283url: https://api.github.com/repos/philipcmonktest/testing/issues/4
286Don't like the textual format? How about we get the raw JSON
290$ cat pt/g/=/gh/=/issues/by-repo/philipcmonktest/testing/7/json | python -m json.tool
293 "avatar_url": "https://avatars.githubusercontent.com/u/16787461?v=3",
294 "events_url": "https://api.github.com/users/philipcmonktest/events{/privacy}",
295 "followers_url": "https://api.github.com/users/philipcmonktest/followers",
296 "following_url": "https://api.github.com/users/philipcmonktest/following{/other_user}",
297 "gists_url": "https://api.github.com/users/philipcmonktest/gists{/gist_id}",
299 "html_url": "https://github.com/philipcmonktest",
301 "login": "philipcmonktest",
302 "organizations_url": "https://api.github.com/users/philipcmonktest/orgs",
303 "received_events_url": "https://api.github.com/users/philipcmonktest/received_events",
304 "repos_url": "https://api.github.com/users/philipcmonktest/repos",
306 "starred_url": "https://api.github.com/users/philipcmonktest/starred{/owner}{/repo}",
307 "subscriptions_url": "https://api.github.com/users/philipcmonktest/subscriptions",
309 "url": "https://api.github.com/users/philipcmonktest"
311 "body": "Yup, that's it. i mean, maybe it's a bit longer than that.\r\n\r\nBut you get the point, right?\r\n\r\nCode `is` cool!",
315 "comments_url": "https://api.github.com/repos/philipcmonktest/testing/issues/7/comments",
316 "created_at": "2016-03-24T22:27:33Z",
317 "events_url": "https://api.github.com/repos/philipcmonktest/testing/issues/7/events",
318 "html_url": "https://github.com/philipcmonktest/testing/issues/7",
324 "url": "https://api.github.com/repos/philipcmonktest/testing/labels/wontfix"
327 "labels_url": "https://api.github.com/repos/philipcmonktest/testing/issues/7/labels{/name}",
331 "repository_url": "https://api.github.com/repos/philipcmonktest/testing",
333 "title": "big news!",
334 "updated_at": "2016-03-24T22:27:33Z",
335 "url": "https://api.github.com/repos/philipcmonktest/testing/issues/7",
337 "avatar_url": "https://avatars.githubusercontent.com/u/16787461?v=3",
338 "events_url": "https://api.github.com/users/philipcmonktest/events{/privacy}",
339 "followers_url": "https://api.github.com/users/philipcmonktest/followers",
340 "following_url": "https://api.github.com/users/philipcmonktest/following{/other_user}",
341 "gists_url": "https://api.github.com/users/philipcmonktest/gists{/gist_id}",
343 "html_url": "https://github.com/philipcmonktest",
345 "login": "philipcmonktest",
346 "organizations_url": "https://api.github.com/users/philipcmonktest/orgs",
347 "received_events_url": "https://api.github.com/users/philipcmonktest/received_events",
348 "repos_url": "https://api.github.com/users/philipcmonktest/repos",
350 "starred_url": "https://api.github.com/users/philipcmonktest/starred{/owner}{/repo}",
351 "subscriptions_url": "https://api.github.com/users/philipcmonktest/subscriptions",
353 "url": "https://api.github.com/users/philipcmonktest"
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