Files
asciinema/README.md

311 lines
11 KiB
Markdown
Raw Normal View History

2017-09-22 20:59:47 +02:00
_Note: This is README for `development` branch. [See the version for latest stable release](https://github.com/asciinema/asciinema/blob/master/README.md)._
2015-03-06 11:59:27 +01:00
# asciinema
2013-10-03 17:57:40 +02:00
2017-09-22 20:59:47 +02:00
[![Build Status](https://travis-ci.org/asciinema/asciinema.svg?branch=develop)](https://travis-ci.org/asciinema/asciinema)
2017-09-16 11:08:32 +02:00
[![PyPI](https://img.shields.io/pypi/v/asciinema.svg)](https://pypi.org/project/asciinema/)
2015-08-07 17:04:55 -04:00
[![license](http://img.shields.io/badge/license-GNU-blue.svg)](https://raw.githubusercontent.com/asciinema/asciinema/master/LICENSE)
2013-10-03 17:57:40 +02:00
2015-03-06 11:59:27 +01:00
Terminal session recorder and the best companion of
[asciinema.org](https://asciinema.org).
2013-10-03 17:57:40 +02:00
2017-09-16 10:36:06 +02:00
[![demo](https://asciinema.org/a/113463.png)](https://asciinema.org/a/113463?autoplay=1)
2013-10-03 17:57:40 +02:00
## Installation
2017-09-16 21:17:19 +02:00
### Python package
asciinema is available on [PyPI](https://pypi.python.org/pypi/asciinema) and can
be installed with pip (Python 3 with setuptools required):
sudo pip3 install asciinema
This is the recommended way of installation, which gives you the latest released
version.
2016-07-05 17:29:33 +02:00
### Native packages
2016-07-05 17:29:33 +02:00
asciinema is included in repositories of most popular package managers on Mac OS
X, Linux and FreeBSD. Look for package named `asciinema`. See the
2015-07-01 20:20:07 +02:00
[list of available packages](https://asciinema.org/docs/installation).
2017-09-16 21:17:19 +02:00
### Snap supported Linux distros
2017-09-17 20:55:12 +02:00
If you run [Ubuntu or other snap supported Linux distribution](https://snapcraft.io/docs/core/install) you can
2017-09-16 21:17:19 +02:00
install asciinema with:
2017-09-16 21:17:19 +02:00
snap install asciinema --classic
2017-09-16 21:17:19 +02:00
The snap contains all necessary dependencies required to run asciinema, and will
get automatically updated when a new version is pushed to the store.
2015-03-06 11:59:27 +01:00
### Docker image
asciinema Docker image is based on Ubuntu 16.04 and has the latest version of
asciinema recorder pre-installed.
docker pull asciinema/asciinema
When running it don't forget to allocate a pseudo-TTY (`-t`), keep STDIN open
(`-i`) and mount config directory volume (`-v`):
docker run --rm -ti -v "$HOME/.config/asciinema":/root/.config/asciinema asciinema/asciinema
Default command run in a container is `asciinema rec`.
There's not much software installed in this image though. In most cases you may
want to install extra programs before recording. One option is to derive new
image from this one (start your custom Dockerfile with `FROM
asciinema/asciinema`). Another option is to start the container with `/bin/bash`
as the command, install extra packages and manually start `asciinema rec`:
docker run --rm -ti -v "$HOME/.config/asciinema":/root/.config/asciinema asciinema/asciinema /bin/bash
root@6689517d99a1:~# apt-get install foobar
root@6689517d99a1:~# asciinema rec
2017-09-22 20:59:47 +02:00
### Running latest version from source code checkout
If none of the above works for you just clone the repo and run asciinema
straight from the checkout.
2017-09-22 20:59:47 +02:00
Clone the repo:
2016-07-05 17:29:33 +02:00
git clone https://github.com/asciinema/asciinema.git
cd asciinema
2017-09-22 20:59:47 +02:00
If you want latest stable version:
git checkout master
If you want current development version:
git checkout develop
Then run it with:
2016-07-05 17:29:33 +02:00
python3 -m asciinema --version
2014-12-18 12:05:44 +01:00
2013-10-03 17:57:40 +02:00
## Usage
2015-08-08 21:25:11 +02:00
asciinema is composed of multiple commands, similar to `git`, `apt-get` or
2015-03-05 15:29:17 +01:00
`brew`.
2015-08-08 21:25:11 +02:00
When you run `asciinema` with no arguments help message is displayed, listing
2015-03-05 15:29:17 +01:00
all available commands with their options.
### `rec [filename]`
__Record terminal session.__
By running `asciinema rec [filename]` you start a new recording session. The
command (process) that is recorded can be specified with `-c` option (see
below), and defaults to `$SHELL` which is what you want in most cases.
Recording finishes when you exit the shell (hit <kbd>Ctrl+D</kbd> or type
`exit`). If the recorded process is not a shell then recording finishes when
the process exits.
2017-09-22 22:59:14 +02:00
If the `filename` argument is omitted then (after asking for confirmation) the
resulting asciicast is uploaded to
[asciinema-server](https://github.com/asciinema/asciinema-server) (by default to
asciinema.org), where it can be watched and shared.
If the `filename` argument is given then the resulting recording (called
[asciicast](doc/asciicast-v2.md)) is saved to a local file. It can later be
replayed with `asciinema play <filename>` and/or uploaded to asciinema server
with `asciinema upload <filename>`.
`ASCIINEMA_REC=1` is added to recorded process environment variables. This
can be used by your shell's config file (`.bashrc`, `.zshrc`) to alter the
2017-09-22 22:59:14 +02:00
prompt or play a sound when the shell is being recorded.
Available options:
2017-10-08 19:47:33 +02:00
* `--stdin` - Enable stdin (keyboard) recording (see below)
* `--append` - Append to existing recording
2017-11-18 16:21:35 +01:00
* `--raw` - Save raw STDOUT output, without timing information or other metadata
2015-03-05 15:29:17 +01:00
* `-c, --command=<command>` - Specify command to record, defaults to $SHELL
2015-08-08 21:25:11 +02:00
* `-t, --title=<title>` - Specify the title of the asciicast
2017-10-26 13:21:38 +02:00
* `-i, --idle-time-limit=<sec>` - Limit recorded terminal inactivity to max `<sec>` seconds
2015-08-08 21:25:11 +02:00
* `-y, --yes` - Answer "yes" to all prompts (e.g. upload confirmation)
* `-q, --quiet` - Be quiet, suppress all notices/warnings (implies -y)
Stdin recording allows for capturing of all characters typed in by the user in
the currently recorded shell. This may be used by a player (e.g.
[asciinema-player](https://github.com/asciinema/asciinema-player)) to display
pressed keys. Because it's basically a key-logging (scoped to a single shell
2017-10-08 19:47:33 +02:00
instance), it's disabled by default, and has to be explicitly enabled via
`--stdin` option.
### `play <filename>`
__Replay recorded asciicast in a terminal.__
This command replays given asciicast (as recorded by `rec` command) directly in
your terminal.
2016-02-21 12:09:33 +01:00
Playing from a local file:
2015-06-23 20:20:22 +02:00
asciinema play /path/to/asciicast.cast
2016-02-21 12:09:33 +01:00
2016-02-21 20:24:20 +01:00
Playing from HTTP(S) URL:
2017-11-10 23:08:20 +01:00
asciinema play https://asciinema.org/a/22124.cast
asciinema play http://example.com/demo.cast
2016-02-21 20:24:20 +01:00
Playing from asciicast page URL (requires `<link rel="alternate"
type="application/asciicast+json" href="....json">` in page's HTML):
2016-02-21 12:09:33 +01:00
asciinema play https://asciinema.org/a/22124
2016-02-21 20:24:20 +01:00
asciinema play http://example.com/blog/post.html
2016-02-21 12:09:33 +01:00
Playing from stdin:
cat /path/to/asciicast.cast | asciinema play -
ssh user@host cat asciicast.cast | asciinema play -
2015-06-23 20:20:22 +02:00
Playing from IPFS:
asciinema play ipfs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V
asciinema play fs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V
2015-05-10 13:53:04 +02:00
Available options:
2017-10-26 13:21:38 +02:00
* `-i, --idle-time-limit=<sec>` - Limit replayed terminal inactivity to max `<sec>` seconds
2017-01-23 16:27:54 +01:00
* `-s, --speed=<factor>` - Playback speedup (can be fractional)
2015-05-10 13:53:04 +02:00
2015-10-21 11:20:26 +02:00
NOTE: it is recommended to run `asciinema play` in a terminal of dimensions not
smaller than the one used for recording as there's no "transcoding" of control
sequences for new terminal size.
2017-11-18 16:57:13 +01:00
### `cat <filename>`
2017-11-18 16:58:43 +01:00
__Print full output of recorded asciicast to a terminal.__
2017-11-18 16:57:13 +01:00
While `asciinema play <filename>` replays the recorded session using timing
information saved in the asciicast, `asciinema cat <filename>` dumps the full
output (including all escape sequences) to a terminal immediately.
2017-11-18 21:16:24 +01:00
`asciinema cat existing.cast >output.txt` gives the same result as recording via
`asciinema rec --raw output.txt`.
### `upload <filename>`
__Upload recorded asciicast to asciinema.org site.__
This command uploads given asciicast (as recorded by `rec` command) to
2017-09-18 09:10:34 +02:00
asciinema.org, where it can be watched and shared.
`asciinema rec demo.cast` + `asciinema play demo.cast` + `asciinema upload
demo.cast` is a nice combo for when you want to review an asciicast before
2015-02-25 16:24:15 +01:00
publishing it on asciinema.org.
### `auth`
2016-07-12 16:12:24 +02:00
__Manage recordings on asciinema.org account.__
If you want to manage your recordings on asciinema.org (set title/description,
delete etc) you need to authenticate. This command displays the URL you should
open in your web browser to do that.
On every machine you run asciinema recorder, you get a new, unique API token. If
you're already logged in on asciinema.org website and you run `asciinema auth`
from a new computer then this new device will be linked to your account.
2013-10-03 17:57:40 +02:00
You can synchronize your config file (which keeps the API token) across the
machines so all of them use the same token, but that's not necessary. You can
assign new tokens to your account from as many machines as you want.
2013-10-03 17:57:40 +02:00
2017-01-28 14:02:54 +01:00
## Hosting the recordings on the web
2017-09-16 11:09:02 +02:00
As mentioned in the `Usage > rec` section above, if the `filename` argument to
2017-11-18 21:26:09 +01:00
`asciinema rec` is omitted then the recorded asciicast is uploaded to
[asciinema.org](https://asciinema.org). You can watch it there and share it via
secret URL.
If you prefer to host the recordings yourself, you can do so by either:
- recording to a file (`asciinema rec demo.cast`), and using [asciinema's
standalone web
player](https://github.com/asciinema/asciinema-player#self-hosting-quick-start)
in your HTML page, or
- setting up your own
[asciinema-server](https://github.com/asciinema/asciinema-server) instance,
and [setting API URL
accordingly](https://github.com/asciinema/asciinema-server/blob/master/docs/INSTALL.md#using-asciinema-recorder-with-your-instance).
2017-01-28 14:02:54 +01:00
2015-03-09 17:05:14 +01:00
## Configuration file
asciinema uses a config file to keep API token and user settings. In most cases
the location of this file is `$HOME/.config/asciinema/config`.
2016-07-05 17:29:33 +02:00
*NOTE: When you first run asciinema, local API token is generated (UUID) and
saved in the file (unless the file already exists or you have set
`ASCIINEMA_API_TOKEN` environment variable).*
2016-07-05 17:29:33 +02:00
The auto-generated, minimal config file looks like this:
2015-03-09 17:05:14 +01:00
[api]
2016-07-05 17:29:33 +02:00
token = <your-api-token-here>
2015-03-09 17:05:14 +01:00
2015-03-10 15:49:35 +01:00
There are several options you can set in this file. Here's a config with all
available options set:
2015-03-09 17:05:14 +01:00
[api]
2016-07-05 17:29:33 +02:00
token = <your-api-token-here>
2015-03-10 15:49:35 +01:00
url = https://asciinema.example.com
2015-03-09 17:05:14 +01:00
[record]
command = /bin/bash -l
stdin = no
env = SHELL,TERM,USER
2017-10-26 13:21:38 +02:00
idle_time_limit = 2
2015-03-09 17:05:14 +01:00
yes = true
quiet = true
2015-03-09 17:05:14 +01:00
2015-05-10 13:53:04 +02:00
[play]
2017-10-26 13:21:38 +02:00
idle_time_limit = 1
2015-05-10 13:53:04 +02:00
2015-03-10 15:49:35 +01:00
The options in `[api]` section are related to API location and authentication.
To tell asciinema recorder to use your own asciinema site instance rather than
the default one (asciinema.org), you can set `url` option. API URL can also be
passed via `ASCIINEMA_API_URL` environment variable, as well as API token, via
`ASCIINEMA_API_TOKEN` environment variable.
2015-03-09 17:05:14 +01:00
2015-05-10 13:53:04 +02:00
The options in `[record]` and `[play]` sections have the same meaning as the
options you pass to `asciinema rec`/`asciinema play` command. If you happen to
often use either `-c`, `-w` or `-y` with these commands then consider saving it
as a default in the config file.
2015-03-09 17:05:14 +01:00
*NOTE: If you want to publish your asciinema config file (in public dotfiles
repository) you __should__ remove `token = ...` line from the file and use
`ASCIINEMA_API_TOKEN` environment variable instead.*
### Configuration file locations
In fact, the following locations are checked for the presence of the config
file (in the given order):
* `$ASCIINEMA_CONFIG_HOME/config` - if you have set `$ASCIINEMA_CONFIG_HOME`
* `$XDG_CONFIG_HOME/asciinema/config` - on Linux, `$XDG_CONFIG_HOME` usually points to `$HOME/.config/`
* `$HOME/.config/asciinema/config` - in most cases it's here
* `$HOME/.asciinema/config` - created by asciinema versions prior to 1.1
2016-07-05 17:29:33 +02:00
The first one found is used.
2013-12-03 20:15:47 +01:00
## Contributing
If you want to contribute to this project check out
2014-02-09 14:05:55 +01:00
[Contributing](https://asciinema.org/contributing) page.
2013-12-03 20:15:47 +01:00
2013-10-06 12:58:29 +02:00
## Authors
2013-10-03 17:57:40 +02:00
2013-10-06 12:58:29 +02:00
Developed with passion by [Marcin Kulik](http://ku1ik.com) and great open
2015-03-05 15:57:12 +01:00
source [contributors](https://github.com/asciinema/asciinema/contributors)
2013-10-06 12:58:29 +02:00
2014-11-15 17:42:04 +01:00
## License
2013-10-06 12:58:29 +02:00
2017-01-28 14:06:13 +01:00
Copyright &copy; 2011-2017 Marcin Kulik.
2014-11-15 17:42:04 +01:00
All code is licensed under the GPL, v3 or later. See LICENSE file for details.