bash_kernel
bash_kernel copied to clipboard
including hml ?
Hi
I am trying to write a tutorial notebook on git, and would like o find a way to somehow include some html/svg that depicts the current repo
coming from mostly python notebooks, I was expecting to find a way to inject some html, but realized this requires python, of course
how would you go about doing that ?
regardless, it's so cool to be able to write bash notebooks, thanks for putting this together :)
ps. i is a piy ha my keyboard can' seem o oupu t's oday ;)
I don't think there's any way to display HTML from bash_kernel at present. I'd be open to some generalisation of the mechanism to display images, but I don't know what would be idiomatic for this kind of thing.
I'm not sure either; it's hard to pick a character sequence that is not meaningful to bash already :)
my first thought was to refer to IPython's magics;
but their regular magic syntax in %
and %%
seems out, as in bash it refers to jobs control
(although my understanding of the current limitations is that job control may be out of reach in a notebook; but still)
although it is technically legal to have command names that include and even start with minuses, it seems unlikely that anyone in their own mind would write a command named -%
or -%%
; so maybe these 2 could be used to define magics ?
that would give us something like
-%html <img src="foo.svg"> </img>
unless we'd rather expect the command stdout to be the html code
-%html-stdout echo '<img src="foo.svg"> </img>'
just thinking aloud here though; I'm not even sure the notion of magic is the right one, as in IPython this specific feature is exposed as an imported function..
I wouldn't try to come up with new syntax for it - rather I'd expose a command, as is already done for images, so you could do e.g. jupyter-display --html
. It could take a filename or even data piped on stdin.
Yes and that was my suggestion too; but as I said I was trying to mimick the magics that IPython has; which probably, you’re right, is just an entirely different matter
Whichever way is fine by me :)
Following up then, we could imagine convenience variants like —svg
or —png
so as to be able to pipe directly out of tools like dot
Yup, I think if we had a generic way to display things, it should support all the formats commonly use in Jupyter. And it should probably also have a way to specify an arbitrary mime-type for less common formats.
We have a version of a bash kernel in metakernel that supports the %%html
magic if you'd like to use that instead, @parmentelat.
pip install git+git://github.com/calysto/metakernel.git#subdirectory=metakernel_bash
python -m metakernel_bash install --user
I was not aware of that, thanks for pointing it out
Is there any piece of background that can be relevant when deciding between these 2 ?
I'm mostly thinking in terms of maturity / support, of course
We just hadn't gone through the trouble of making it a separate package or advertising it. We use it for unit tests primarily. However, its sibling kernels, that share a lot of the same logic, are quite mature and widely used. If there were demand, we could make it published package.
Ok thanks
I’ll start with using them alongside one another :)
I take it the same sort of limitation applies in terms of running interactive tools that expect stdin to be a terminal?
That is correct, we are using the same underlying mechanism to communicate with bash.
@parmentelat, I completely forgot we had already created a separate bash kernel with magics. You can install it as pip install calysto_bash
.
I missed the thread before because of the mispelling, so I never saw calysto_bash ...
But I did put together a PR to add support to HTML, if anyone is interested. It also include other goodies (progress-bar output support, a trivial environment variable to tell programs it is in a bash_kernel and it can output rich content, etc.)
https://github.com/takluyver/bash_kernel/pull/122
implemented by @janpfeifer in #122