{"id":13557604,"url":"https://github.com/takluyver/bash_kernel","last_synced_at":"2025-05-14T03:06:25.797Z","repository":{"id":18160142,"uuid":"21259107","full_name":"takluyver/bash_kernel","owner":"takluyver","description":"A bash kernel for IPython","archived":false,"fork":false,"pushed_at":"2025-01-05T15:19:13.000Z","size":683,"stargazers_count":720,"open_issues_count":14,"forks_count":142,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-04T13:01:45.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takluyver.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-27T00:27:25.000Z","updated_at":"2025-03-30T00:41:16.000Z","dependencies_parsed_at":"2024-01-14T03:49:38.008Z","dependency_job_id":"2573c03a-1979-4943-b624-61b3a8a02a4b","html_url":"https://github.com/takluyver/bash_kernel","commit_stats":{"total_commits":95,"total_committers":20,"mean_commits":4.75,"dds":0.6,"last_synced_commit":"e6f0b066b1b99048a44b89968306b61fed1629b6"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takluyver%2Fbash_kernel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takluyver%2Fbash_kernel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takluyver%2Fbash_kernel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takluyver%2Fbash_kernel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takluyver","download_url":"https://codeload.github.com/takluyver/bash_kernel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248465293,"owners_count":21108243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:04:26.725Z","updated_at":"2025-04-11T18:59:25.882Z","avatar_url":"https://github.com/takluyver.png","language":"Python","readme":".. image:: https://mybinder.org/badge_logo.svg\n :target: https://mybinder.org/v2/gh/takluyver/bash_kernel/master\n\n=========================\nA Jupyter kernel for bash\n=========================\n\nInstallation\n------------\nThis requires IPython 3.\n\n.. code:: shell\n\n    pip install bash_kernel\n    python -m bash_kernel.install\n\nTo use it, run one of:\n\n.. code:: shell\n\n    jupyter notebook\n    # In the notebook interface, select Bash from the 'New' menu\n    jupyter qtconsole --kernel bash\n    jupyter console --kernel bash\n\n\n`pipx` and \"externally managed\" environments\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nA recent-ish `PEP 668 \u003chttps://peps.python.org/pep-0668/#guide-users-towards-virtual-environments\u003e`_ recommends that users install Python applications with `pipx` rather than global installs with `pip`. This is strongly suggested/enforced in current Linux distros. Because `bash_kernel` needs an extra step to actually work after installing with `pip` or `pipx`, this causes some inconvenience.\n\nFirst, one must install the Jupyter ecosystem with pipx, and then inject bash_kernel (and any other bits of the jupyter ecosystem you use, like papermill) into the same pipx venv.\n\n.. code:: shell\n\n    pipx install --include-deps jupyter\n    pipx inject --include-apps --include-deps jupyter bash_kernel\n\nOne then must manually find the corresponding venv, activate it, and run `python -m bash_kernel.install` *within* that virtual env. If done outside it, this won't work as bash_kernel is not installed in the global environment.\n\n.. code:: shell\n\n    cd ~/.local/pipx/venvs/jupyter/\n    source bin/activate\n    python -m bash_kernel.install\n    deactivate\n\nOf course, one can also install bash_kernel to the global environement thusly:\n\n.. code:: shell\n\n    pip install --break-system-packages juptyer bash_kernel\n    python -m bash_kernel.install\n\nRequirements of Bash\n~~~~~~~~~~~~~~~~~~~~\n\nBash kernel directly interacts with bash, and therefore requires a functioning interactive build of bash. In nearly all cases this will be the default, however some distributions remove GNU readline or other interactivity features of bash. Almost always, these features are provided in a separate, more complete bash package, which should be installed. See for example https://github.com/takluyver/bash_kernel/issues/142.\n\nDisplaying Rich Content\n-----------------------\n\nTo use specialized content (images, html, etc) this file defines (in `build_cmds()`) bash functions\nthat take the contents as standard input. Currently, `display` (images), `displayHTML` (html)\nand `displayJS` (javascript) are supported.\n\nExample:\n\n.. code:: shell\n\n    cat dog.png | display\n    echo \"\u003cb\u003eDog\u003c/b\u003e, not a cat.\" | displayHTML\n    echo \"alert('Hello from bash_kernel\\!');\" | displayJS\n\nUpdating Rich Content Cells\n---------------------------\n\nIf one is doing something that requires dynamic updates, one can specify a unique display_id,\nwhich should be a string name. On each update, the contents will be replaced by the new value. Example:\n\n.. code:: shell\n\n    display_id=\"id_${RANDOM}\"\n    ((ii=0))\n    while ((ii \u003c 10)) ; do\n        echo \"\u003cdiv\u003e${ii}\u003c/div\u003e\" | displayHTML $display_id\n        ((ii = ii+1))\n        sleep 1\n    done\n\nThe same works for images and javascript content.\n\n**Remember to create always a new id** each time the cell is executed, otherwise it will try to display\non an HTML element that no longer exists (they are erased each time a cell is re-run).\n\nProgrammatically Generating Rich Content\n----------------------------------------\n\nAlternatively one can simply generate the rich content to a file in /tmp (or $TMPDIR)\nand then output the corresponding (to the mimetype) context prefix ``\"_TEXT_SAVED_*\"``\nconstant. So one can write programs (C++, Go, Rust, etc.) that generates rich content\nappropriately, when within a notebook.\n\nThe environment variable \"NOTEBOOK_BASH_KERNEL_CAPABILITIES\" will be set with a comma\nseparated list of the supported types (currently \"image,html,javascript\") that a program\ncan check for.\n\nTo output to a particular \"display_id\", to allow update of content (e.g: dynamically\nupdating/generating a plot from a command line program), prefix the filename\nwith \"(\u003cdisplay_id\u003e)\". E.g: a line to display the contents of /tmp/myHTML.html to\na display id \"id_12345\" would look like:\n\n    bash_kernel: saved html data to: (id_12345) /tmp/myHTML.html\n\nMore Information\n----------------\n\nFor details of how this works, see the Jupyter docs on `wrapper kernels\n\u003chttp://jupyter-client.readthedocs.org/en/latest/wrapperkernels.html\u003e`_, and\nPexpect's docs on the `replwrap module\n\u003chttp://pexpect.readthedocs.org/en/latest/api/replwrap.html\u003e`_.\n","funding_links":[],"categories":["Python","others","Jupyter Kernels","Jupyter内核"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakluyver%2Fbash_kernel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakluyver%2Fbash_kernel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakluyver%2Fbash_kernel/lists"}