xonsh

Python-powered shell. Full-featured, cross-platform and AI-friendly.

BSD 2-Clause License 159 个版本 Python >=3.11
安装
pip install xonsh
poetry add xonsh
pipenv install xonsh
conda install xonsh
描述

Xonsh

.. raw:: html

<img src="https://avatars.githubusercontent.com/u/17418188?s=200&v=4" alt="Xonsh shell icon." align="left" width="100px">

Xonsh (sounds like "consh") is a full-featured and cross-platform Python-based shell. The language is a superset of Python 3 with seamless integration of shell functionality and commands. It works on all major platforms, including Linux, macOS, Windows, BSD, Jupyter, Android and Raspberry Pi.

.. raw:: html

<br clear="left"/>

.. list-table:: :widths: 1 1

    • Xonsh is the Shell
    • Xonsh is Python
    • .. code-block:: shell

      cd $HOME

      id $(whoami) > ~/id.txt

      cat /etc/passwd | grep root

      $PROMPT = '@ '

    • .. code-block:: python

      2 + 2

      var = "hello".upper()

      @.imp.json.loads('{"a":1}')

      [i for i in range(0,10)]

    • Xonsh is the Shell in Python
    • Xonsh is Python in the Shell
    • .. code-block:: python

      len($(curl -L https://xon.sh))

      $PATH.append('/tmp')

      p'/etc/passwd'.read_text().find('usr')

      $(@json podman ps --format json)['ID']

    • .. code-block:: python

      name = 'snail' echo @(name) > /tmp/@(name)

      with p'/tmp/dir'.mkdir().cd(): touch @(input('File: '))

      aliases['e'] = 'echo @(2+2)' aliases['a'] = lambda args: print(args)

    • Xonsh is Everywhere
    • Xonsh is an Ecosystem
    • .. code-block:: python

      $PATH

      ['/bin', '/sbin'] # Linux

      ['/homebrew/bin'] # macOS

      ['/usr/local/bin'] # FreeBSD

      ['/mnt/c/Windows/System32'] # WSL

      [r'c:\Windows\System32'] # Windows

      ['/nix/store/0-python/bin'] # Nix

      ['/data/termux/usr/bin'] # Termux

      ['/tmp/.mount_x/usr/bin/'] # AppImage

      ['/app/bin'] # Flatpak

      $PATH = ['/my/own/path']

    • .. code-block:: python

      xontrib load term_integration
      prompt_starship
      powerline
      dracula
      chatgpt
      django
      jupyter
      1password
      github_copilot
      history_encrypt

    • Xonsh is a Meta-Shell
    • Xonsh is User-extensible
    • .. code-block:: python

      xontrib load sh
      fish_completer

      def nudf(cmd): return @.imp.pandas.DataFrame( @.imp.json.loads( $(nu -c @(cmd+'| to json')))) nudf!(ls -la)

      aliases['ai'] = 'ollama run llama3' ai! how to remove images in podman

    • .. code-block:: python

      @events.on_ptk_create def custom_keybindings(bindings, **kw): @bindings.add(Keys.ControlI) def say_whoami(event): echo $(whoami)

      @events.on_postcommand def _prompt_err_cmd(cmd, rtn, out, ts): if rtn != 0: $XONSH_PROMPT_NEXT_CMD = cmd.rstrip()

If you like xonsh, :star: the repo and spread the word about xonsh.

.. class:: center

.. image:: https://img.shields.io/badge/Zulip%20Community-xonsh-green
        :target: https://xonsh.zulipchat.com/
        :alt: Join to xonsh.zulipchat.com

.. image:: https://repology.org/badge/tiny-repos/xonsh.svg
        :target: https://repology.org/project/xonsh/versions
        :alt: repology.org

.. image:: https://img.shields.io/badge/Docker%20Hub-xonsh-blue
        :target: https://hub.docker.com/u/xonsh
        :alt: hub.docker.com

.. image:: https://img.shields.io/badge/AppImage-xonsh-lightblue
        :target: https://xon.sh/appimage.html
        :alt: AppImage

.. image:: https://github.com/xonsh/xonsh/actions/workflows/test.yml/badge.svg
        :target: https://github.com/xonsh/xonsh/actions/workflows/test.yml
        :alt: GitHub Actions

.. image:: https://codecov.io/gh/xonsh/xonsh/branch/master/graphs/badge.svg?branch=main
        :target: https://codecov.io/github/xonsh/xonsh?branch=main
        :alt: codecov.io

First steps


  • Installation <https://xon.sh/install.html>_ - isolated environment, package, container or portable AppImage.
  • Tutorial <https://xon.sh/tutorial.html>_ - step by step introduction in Xonsh.

Extensions


Xonsh has an extension/plugin system. We call these additions xontribs.

  • Xontribs on Github <https://github.com/topics/xontrib>_
  • Awesome xontribs <https://github.com/xonsh/awesome-xontribs>_
  • Core xontribs <https://xon.sh/api/_autosummary/xontribs/xontrib.html>_
  • Create a xontrib step by step from template <https://github.com/xonsh/xontrib-template>_

Projects that use Xonsh or compatible


  • Assistant <https://gitlab.com/waser-technologies/technologies/assistant>_: An AI-powered shell with a full Xonsh terminal and a multi-agent LLM system.
  • CrateDB <https://github.com/crate>_: The Database for Real-Time Analytics and Hybrid Search.
  • conda <https://conda.io/projects/conda/en/latest/>_ and mamba <https://mamba.readthedocs.io/en/latest/>_: Cross-platform package managers.
  • Starship <https://starship.rs/>_: Cross-shell prompt.
  • zoxide <https://github.com/ajeetdsouza/zoxide>_: A smarter cd command.
  • gitsome <https://github.com/donnemartin/gitsome>_: Supercharged Git/shell autocompleter with GitHub integration.
  • xxh <https://github.com/xxh/xxh>_: Using Xonsh wherever you go through the SSH.
  • kash <https://github.com/jlevy/kash>_: The knowledge agent shell.
  • Snakemake <https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#xonsh>_: A workflow management system to create reproducible and scalable data analyses.
  • any-nix-shell <https://github.com/haslersn/any-nix-shell>_: Xonsh support for the nix run and nix-shell environments of the Nix package manager.
  • lix <https://github.com/lix-project/lix>_: A modern, delicious implementation of the Nix package manager.
  • x-cmd <https://www.x-cmd.com/>_: x-cmd is a vast and interesting collection of tools guided by the Unix philosophy.
  • rever <https://regro.github.io/rever-docs/>_: Cross-platform software release tool.
  • Regro autotick bot <https://github.com/regro/cf-scripts>_: Regro Conda-Forge autoticker.

Jupyter-based interactive notebooks via xontrib-jupyter <https://github.com/xonsh/xontrib-jupyter>_:

  • Jupyter and JupyterLab <https://jupyter.org/>_: Interactive notebook platform.
  • Euporie <https://github.com/joouha/euporie>_: Terminal based interactive computing environment.
  • Jupytext <https://jupytext.readthedocs.io/>_: Clear and meaningful diffs when doing Jupyter notebooks version control.

Compiling, packaging, or accelerating Xonsh:

  • AppImage <https://github.com/appimage>_ is a format for distributing Linux applications and can be used to create a standalone xonsh package <https://xon.sh/appimage.html>_.
  • Nuitka <https://github.com/Nuitka/Nuitka>_ is an optimizing Python compiler that can build a native Xonsh binary <https://github.com/xonsh/xonsh/issues/2895#issuecomment-3665753657>_.
  • RustPython <https://github.com/RustPython/RustPython/>_ is a Python interpreter written in Rust that can run xonsh on top of Rust <https://github.com/xonsh/xonsh/issues/5082#issue-1611837062>_.

Welcome to the Xonsh shell community


The Xonsh shell is developed by a community of volunteers. There are a few ways to help out:

  • Write a note or an article about Xonsh.
  • Send a link to Xonsh to your favorite blogger.
  • Add Xonsh support in third party tool: package manager <https://github.com/topics/package-manager>, terminal emulator <https://github.com/topics/terminal-emulators>, console tool <https://github.com/topics/console>, IDE <https://github.com/topics/ide>.
  • Give a star to Xonsh repository and to xontribs <https://github.com/topics/xontrib>_ you like.
  • Solve a popular issue <https://github.com/xonsh/xonsh/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc>_ or high priority issue <https://github.com/xonsh/xonsh/issues?q=is%3Aopen+is%3Aissue+label%3Apriority-high+sort%3Areactions-%2B1-desc>_ or a good first issue <https://github.com/xonsh/xonsh/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+sort%3Areactions-%2B1-desc>. You can start with the Developer guide <https://xon.sh/devguide.html>. Feel free to use LLM e.g. Github Copilot <https://github.com/copilot>_.
  • Take an idea <https://github.com/xonsh/xontrib-template/issues?q=is%3Aopen+is%3Aissue+label%3Aidea+sort%3Areactions-%2B1-desc>_ and create a new xontrib <https://github.com/xonsh/xontrib-template#why-use-this-template>_.
  • Contribute to Xonsh API <https://github.com/xonsh/xonsh/tree/main/xonsh/api>_.
  • Become Xonsh core developer by deep diving into xonsh internals. E.g. we feel a lack of Windows support.
  • Test Xonsh with compiler, interpreter, optimizer and report upstream issues (e.g. Nuitka <https://github.com/xonsh/xonsh/issues/2895#issuecomment-3665753657>, RustPython <https://github.com/xonsh/xonsh/issues/5082#issue-1611837062>).
  • Design more logos and images <https://github.com/anki-code/xonsh-logo>, improve Xonsh website <https://xon.sh/> (src <https://github.com/xonsh/xonsh/blob/12f12ce94f1b6c92218e22fbdaaa846e16ac8b2d/docs/_templates/index.html#L9>_).
  • Become a sponsor to Xonsh <https://github.com/sponsors/xonsh>_.

We welcome new contributors!

Credits


  • Thanks to Zulip <https://zulip.com/>_ for supporting the Xonsh community <https://xonsh.zulipchat.com/>_!
  • Thanks to HELLOTUX <https://www.hellotux.com/>_ for distributing the Xonsh t-shirts, backpacks and more <https://www.hellotux.com/xonsh>_!
  • Thanks to ADS.FUND for supporting Xonsh token <https://ads.fund/token/0xadf7478450b69a349ed9634b18584d2d3da81464>_!
版本列表
0.23.8 2026-05-30
0.23.7 2026-05-17
0.23.6 2026-05-11
0.23.5 2026-05-05
0.23.4 2026-05-03
0.23.3 2026-04-30
0.23.2 2026-04-26
0.23.1 2026-04-21
0.23.0 2026-04-20
0.22.8 2026-03-17
0.22.7 2026-03-10
0.22.6 2026-03-05
0.22.5 2026-03-05
0.22.4 2026-02-17
0.22.3 2026-02-04
0.22.2 2026-02-03
0.22.1 2026-01-14
0.22.0 2025-12-19
0.21.2 2025-12-10
0.21.1 2025-12-10
0.21.0 2025-12-10
0.20.0 2025-11-24
0.19.9 2025-06-24
0.19.8 2025-06-24
0.19.3 2025-03-19
0.19.2 2025-02-11
0.19.1 2025-01-13
0.19.0 2024-12-09
0.18.4 2024-11-02
0.18.3 2024-08-20
0.18.2 2024-07-18
0.18.1 2024-07-17
0.17.0 2024-06-18
0.16.0 2024-04-23
0.15.1 2024-03-07
0.15.0 2024-02-25
0.14.4 2024-01-16
0.14.3 2023-12-05
0.14.2 2023-11-17
0.14.1 2023-08-16
0.14.0 2023-05-19
0.13.4 2022-12-08
0.13.3 2022-09-15
0.13.2 2022-09-15
0.13.1 2022-08-10
0.13.0 2022-07-08
0.12.6 2022-06-21
0.12.5 2022-06-17
0.12.4 2022-05-08
0.12.3 2022-05-08
0.12.2 2022-04-25
0.12.1 2022-04-15
0.12.0 2022-04-14
0.11.0 2021-11-17
0.10.1 2021-07-24
0.10.0 2021-07-24
0.9.27 2021-03-03
0.9.26 2021-02-04
0.9.25 2021-01-29
0.9.24 2020-10-16
0.9.23 2020-10-08
0.9.22 2020-09-16
0.9.21 2020-09-02
0.9.20 2020-08-26
0.9.19 2020-08-09
0.9.18 2020-05-05
0.9.17 2020-04-08
0.9.16 2020-04-07
0.9.15 2020-03-19
0.9.14 2020-02-28
0.9.13 2019-10-15
0.9.12 2019-10-06
0.9.11 2019-08-25
0.9.10 2019-08-09
0.9.9 2019-07-19
0.9.8 2019-07-08
0.9.7 2019-06-28
0.9.6 2019-06-10
0.9.5 2019-05-31
0.9.4 2019-05-22
0.9.3 2019-05-14
0.9.2 2019-05-14
0.9.1 2019-05-11
0.9.0 2019-05-09
0.8.12 2019-03-11
0.8.11 2019-02-27
0.8.10 2019-02-07
0.8.9 2019-01-31
0.8.8 2019-01-04
0.8.7 2018-12-28
0.8.6 2018-12-21
0.8.5 2018-12-14
0.8.4 2018-12-07
0.8.3 2018-11-07
0.8.2 2018-10-31
0.8.1 2018-10-18
0.8.0 2018-10-10
0.7.10 2018-09-26
0.7.9 2018-09-18
0.7.8 2018-09-11
0.7.7 2018-08-30
0.7.6 2018-08-21
0.7.5 2018-08-16
0.7.4 2018-08-15
0.7.3 2018-08-07
0.7.2 2018-07-30
0.7.1 2018-07-23
0.7.0 2018-07-16
0.6.10 2018-07-11
0.6.9 2018-07-06
0.6.8 2018-06-29
0.6.7 2018-06-15
0.6.6 2018-06-06
0.6.5 2018-05-28
0.6.4 2018-05-17
0.6.3 2018-05-04
0.6.2 2018-04-24
0.6.1 2018-04-14
0.6.0 2017-11-23
0.5.12 2017-06-10
0.5.10 2017-05-25
0.5.9 2017-03-15
0.5.8 2017-03-08
0.5.7 2017-03-01
0.5.6 2017-02-22
0.5.5 2017-02-15
0.5.4 2017-02-08
0.5.3 2017-02-01
0.5.2 2017-01-05
0.5.1 2016-12-21
0.5.0 2016-12-20
0.4.7 2016-10-02
0.4.6 2016-09-01
0.4.5 2016-08-17
0.4.4 2016-07-21
0.4.3 2016-06-30
0.4.2 2016-06-26
0.4.1 2016-06-24
0.4.0 2016-06-24
0.3.4 2016-06-08
0.3.3 2016-06-06
0.3.2 2016-05-30
0.3.1 2016-05-28
0.3.0 2016-05-20
0.2.7 2016-03-20
0.2.6 2016-02-07
0.2.5 2016-01-22
0.2.4 2015-12-30
0.2.3 2015-11-07
0.2.2 2015-10-12
0.2.1 2015-10-12
0.2.0 2015-09-13
0.1.6 2015-05-29
0.1.5 2015-04-09
0.1.4 2015-03-30
0.1.3 2015-03-23
0.1.2 2015-03-15
0.1.1 2015-03-11
0.1.0 2015-03-09