doitlive

Because sometimes you need to do it live

Current version: v2.3.0.

doitlive is a tool for live presentations in the terminal. It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.

Get it now

MacOSX with Homebrew:

$ brew update
$ brew install doitlive

With pip:

$ pip install doitlive

Requires Python >= 2.7 or >= 3.3 with pip.

Quickstart

  1. Create a file called session.sh. Fill it with bash commands.
  2. Run doitlive play session.sh.
$ doitlive play session.sh
  1. Type like a madman.

Examples

# Use the "sorin" prompt theme
$ doitlive play session.sh -p sorin

# Increase speed
$ doitlive play session.sh -s 3

# Use zsh
$ doitlive play session.sh --shell /bin/zsh

Using the recorder

You can record session files using the built-in recorder command.

$ doitlive record

This will start a recording session. When you are finished recording, run the stop command. All commands will be written to a session.sh file.

Themes

doitlive comes with many prompt themes. To use a theme:

$ doitlive play session.sh -p <theme_name>

You can also change a session’s theme by using a comment directive (see Comment magic below).

To view a list of available themes, run doitlive themes or doitlive themes --preview.

Comment magic (configuration)

Any line in a session file that begins with # is a comment. Comments are ignored unless they begin with #doitlive, in which case they are used to configure the session.

The following options can be included at the top of your session file (all are optional).

#doitlive speed: <int>

configures “typing” speed. Defaults to 1.

Example: #doitlive speed: 3

#doitlive prompt: <theme_name_or_template>

configures the prompt. Can be any of the built-in themes or a custom prompt template.

Using a custom template:

You can provide the prompt option with a custom template. To include the user, hostname, current directory, current path to working directory, current datetime, or vcs branch (git or Mercurial), use {user}, {hostname}, {dir}, {cwd}, {now}, and {vcs_branch}, respectively.

For git, {vcs_branch} just shows the branch. For Mercurial, this shows the branch name + the bookmark, except it omits the default branch name if there is a bookmark. This is equivalent to {git_branch}{hg_id}. There are also specialised {hg_branch}, and {hg_bookmark} keywords that only show that information, without the combined logic of {hg_id}.

Example: #doitlive prompt: {user} is at {cwd} $

Any of the prompt variables can be formatted with ANSI styles, like so:

Example: #doitlive prompt: {user.cyan}@{hostname.green}:{dir.bold.magenta} $

Available styles: blue, magenta, red, white, green, black, yellow, cyan, bold, blink, underlined, dim, paren, square, curly, git, and hg.

#doitlive shell: <shell>

configures which shell is use.

Example: #doitlive shell: /bin/zsh

#doitlive alias: <alias>=<command>

adds an alias to the session.

Example: #doitlive alias: du="du -ach | sort -h"

#doitlive env: <envvar>=<value>

sets an environment variable.

Example: #doitlive env: EDITOR=vim

#doitlive unalias: <alias>

removes an alias.

#doitlive unset: <envvar>

unsets an environment variable.

#doitlive commentecho: [true|false]

Whether to echo comments or not. If enabled, non-magic comments will be echoed back in bold yellow before each prompt. This can be useful for providing some annotations for yourself and the audience.

Python mode

doitlive supports autotyping in a Python console. You can enter Python mode in a session by enclosing Python code in triple-backticks within your session.sh file, like so:

# in session.sh

echo "And now for something completely different"

```python
list = [2, 4, 6, 8]
sum = 0
for num in list:
    sum = sum + num

print("The sum is: {sum}".format(sum=sum))
```

Bash completion

To enable bash completion, add the following to your .bashrc or .bash_profile.

eval "$(_DOITLIVE_COMPLETE=source doitlive)"

Completion is currently only supported for bash.

More

For more options, run

$ doitlive --help

You can also get help with subcommands.

$ doitlive play --help
Fork me on GitHub