takluyver/bash_kernel — pull request #10 by jeroenjanssens (2014-12-07 13:17:15+00:00)
Title: Add ability to show inline images

This pull request adds the ability to show inline images. It basically works by registering a Bash function called `display` when the kernel starts. This function saves the standard input to a temporary file and prints the filename to to standard error:

```console
$ type display
display is a function
display ()
{
TMPFILE=$(mktemp ${TMPDIR-/tmp}/bash_kernel.XXXXXXXXXX);
cat > $TMPFILE;
echo "bash_kernel: saved image data to: $TMPFILE" 1>&2
}
```

The Bash kernel simply extracts the filenames (if any) from the output, detects the MIME type, and sends the appropriate display data. `display` is a function that accepts data from standard input, so it allows you to display image data as follows:

```console
< image.png display
```

The name `display` is chosen because `display` is also [a command-line tool from ImageMagick](http://www.imagemagick.org/script/display.php) that accepts image data from standard input and displays a popup. Because that tool doesn't work without X, I figured that the function `display` could serve as a drop-in replacement when using IPython notebook.