• Stars
    star
    651
  • Rank 69,175 (Top 2 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A bash kernel for IPython

A Jupyter kernel for bash

Installation

This requires IPython 3.

pip install bash_kernel
python -m bash_kernel.install

To use it, run one of:

jupyter notebook
# In the notebook interface, select Bash from the 'New' menu
jupyter qtconsole --kernel bash
jupyter console --kernel bash

Displaying Rich Content

To use specialized content (images, html, etc) this file defines (in build_cmds()) bash functions that take the contents as standard input. Currently, display (images), displayHTML (html) and displayJS (javascript) are supported.

Example:

cat dog.png | display
echo "<b>Dog</b>, not a cat." | displayHTML
echo "alert('It is known khaleesi\!');" | displayJS

Updating Rich Content Cells

If one is doing something that requires dynamic updates, one can specify a unique display_id, should be a string name (downstream documentation is not clear on this), and the contents will be replaced by the new value. Example:

display_id="id_${RANDOM}"
((ii=0))
while ((ii < 10)) ; do
    echo "<div>${ii}</div>" | displayHTML $display_id
    ((ii = ii+1))
    sleep 1
done

The same works for images or even javascript content.

Remember to create always a new id (random ids works perfect) each time the cell is executed, otherwise it will try to display on an HTML element that no longer exists (they are erased each time a cell is re-run).

Programmatically Generating Rich Content

Alternatively one can simply generate the rich content to a file in /tmp (or $TMPDIR) and then output the corresponding (to the mimetype) context prefix "_TEXT_SAVED_*" constant. So one can write programs (C++, Go, Rust, etc.) that generates rich content appropriately, when within a notebook.

The environment variable "NOTEBOOK_BASH_KERNEL_CAPABILITIES" will be set with a comma separated list of the supported types (currently "image,html,javascript") that a program can check for.

To output to a particular "display_id", to allow update of content (e.g: dynamically updating/generating a plot from a command line program), prefix the filename with "(<display_id>)". E.g: a line to display the contents of /tmp/myHTML.html to a display id "id_12345" would look like:

bash_kernel: saved html data to: (id_12345) /tmp/myHTML.html

More Information

For details of how this works, see the Jupyter docs on wrapper kernels, and Pexpect's docs on the replwrap module.

More Repositories

1

pynsist

Build Windows installers for Python applications
Python
850
star
2

cite2c

Citations in the Jupyter Notebook
JavaScript
313
star
3

nbopen

Open a Jupyter notebook in the best available server
Python
293
star
4

igo

(Unmaintained) Go Kernel for Jupyter
Go
123
star
5

nbparameterise

Programmatically replace input values in a notebook before running it
Python
112
star
6

mobilechelonian

Turtles on a notebook
JavaScript
99
star
7

bookbook

Tools to use a collection of notebooks as 'chapters'
Python
97
star
8

pyxdg

PyXDG provides Python implementations of various freedesktop.org specifications. This is the Giithub mirror.
Python
78
star
9

entrypoints

Discover and load entry points from installed packages
Python
72
star
10

astsearch

Intelligently search in Python code
Python
66
star
11

Unidecode

A python module to reduce Unicode to a 'good enough' ASCII representation (outdated Github copy)
Python
29
star
12

ubit_kernel

Jupyter kernel for the BBC micro:bit
Python
23
star
13

weatbag

Written by Everyone Altogether, The Big Adventure Game
Python
21
star
14

ZeroRPC

Simple RPC for Python programs, using ZeroMQ
Python
20
star
15

jupyter-intro-xfel-jan17

Introduction to Jupyter Notebook
Jupyter Notebook
18
star
16

astcheck

Check Python ASTs against templates
Python
17
star
17

tabipy

Display tables in IPython
Python
17
star
18

reversion

Easily update version numbers across your project
Python
16
star
19

backcall

Backwards compatible callback APIs
Python
16
star
20

py-nsis-template

Template for a Python application installer
Shell
15
star
21

jupyter_kernel_mgmt

Experimental new kernel management framework for Jupyter
Python
15
star
22

wheel2conda

Convert pure-Python wheels to conda packages (experimental)
Python
11
star
23

nbconvert-reportlab

Jupyter Notebook
11
star
24

nbexplode

Explode a notebook into a directory of files, and recombine it to a .ipynb
Python
11
star
25

requests_download

Download to a local file using requests
Python
10
star
26

flonda

Conda packages from flit information
Python
10
star
27

pygame

Mirror of pygame repo
C
10
star
28

pandawash

Magic commands to quickly & transparently clean up data
Python
9
star
29

customising-nbconvert

Talk for PyData London 2016
HTML
8
star
30

europython-2017-talk

Jupyter Notebooks for Teaching and Learning
7
star
31

pygame-flatpak-test

Flatpak packaging of pygame games (experimental)
Python
7
star
32

recombinecm

Separating & recombining Jupyter notebook storage, to version control without outputs
Python
7
star
33

pyqt-app-template

Cookiecutter template for a PyQt4 application
Python
6
star
34

hello_jupyter_proxy

A minimal example server to run with jupyter-server-proxy
Python
6
star
35

redsnail

The command line that shows you where you are
JavaScript
5
star
36

wheeldex

Indexing Python wheels
Python
5
star
37

jupyter_protocol

Experimental
Python
5
star
38

bisect-demo

Demoing git bisect
Python
5
star
39

ucb-ipython-intro

IPython intro lecture at UC Berkeley, 2 March 2015
Python
4
star
40

intreehooks

Load a PEP 517 backend from inside the source tree
Python
4
star
41

tox_appveyor

Select 32 or 64-bit Python for Tox on Appveyor
Python
4
star
42

r2_kernel

R wrapper kernel for IPython
Python
4
star
43

calcurust

A sample Jupyter kernel in Rust
Rust
3
star
44

ARE

An alternative R environment for Linux
Python
3
star
45

damnpth

Forcibly fix setuptools' .pth files
Python
3
star
46

euroscipy-2017-nbval

Nbval talk at Euroscipy 2017
Jupyter Notebook
3
star
47

Zantedeschia

Experimental ZMQ integration with asyncio
Python
2
star
48

jupyter_ssh_kernels

Python
2
star
49

hdf5-units

WIP specification for recording units in HDF5 files
2
star
50

altwidgets-prototype

JavaScript
2
star
51

importtracer

Track Python imports
Python
2
star
52

pyqt4_windows_whl

Python
2
star
53

cell2function

IPython extension to convert a cell to a function
Python
2
star
54

sqlite-glance

Inspect an SQLite database in the terminal
Rust
2
star
55

tornado_xstatic

Utilities for using XStatic in Tornado applications
Python
2
star
56

spotting-stat-claims

Fullfact hackathon - identifying statistical claims
Jupyter Notebook
1
star
57

ipython-sfpython-feb-2015

Talk about IPython for SFPython, February 2015
1
star
58

XStatic-termjs

A terminal written in Javascript, packaged for Python
JavaScript
1
star
59

flit_install_py2

Shim to install packages using flit metadata on Python 2
Python
1
star
60

deskent

Find and inspect .desktop files
Rust
1
star
61

installmod

Install a Python package using conda or pip as appropriate
Python
1
star
62

jupyter_docker_kernels

Experimental docker kernels for Jupyter
Python
1
star
63

nbhtml

Save & load Jupyter notebooks as HTML
HTML
1
star
64

cern-jupyter-presentation

Presentation about Jupyter, 10 Dec 2015 at CERN
Jupyter Notebook
1
star
65

blog

Python
1
star
66

aiokernel

Experimental asyncio-based Python kernel for IPython
Python
1
star