# XONSH is a Python-powered shell

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.

Install Docs Code Sponsor

## What is Xonsh?

Xonsh (sounds like "consh") is a Python-based shell that seamlessly extends Python with powerful command-line functionality and integration with the operating system.

### Xonsh is the Shell

The xonsh language provides the shell primitives commonly found in traditional Unix shells, including interaction with standard utilities, pipelines, and input/output streams.

    cd $HOME

    id $(whoami) > ~/id.txt

    cat /etc/passwd | grep root

    $PROMPT = '@ '

### Xonsh is Python

The xonsh language is a superset of Python 3, allowing you to execute Python code directly, install and use third-party libraries, import modules, and take advantage of the broader Python ecosystem and tooling.

    2 + 2

    var = "hello".upper()

    import json; json.loads('{"a":1}')

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

### Xonsh is the Shell in Python

Xonsh provides a unified environment where shell functionality and Python code work together naturally.

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

    $PATH.append('/tmp')

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

    id = $(@json podman ps --format json)['ID']
    cfg = $(@yaml cat config.yaml)

    @.imp.pathlib.Path('~/bin').exists()

### Xonsh is Python in the Shell

Xonsh shell session builtins allow xonsh to function as a fully featured shell, tightly integrated with the operating system and its environment.

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

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

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

### Xonsh is a Meta-Shell

Xonsh can orchestrate and unify other shells and tools, allowing you to combine external programs into a single programmable environment.

    xontrib load sh \
                 fish_completer

    osqueryi ! SELECT platform FROM os_version

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

    nudf!(ls -la)

    aliases['ai'] = 'ollama run llama3'
    ai! command to remove images from podman

### Xonsh is an Ecosystem

Xonsh extends beyond a shell through xontribs — community-driven plugins that integrate frameworks, developer tools, AI assistants, themes, and system features into a cohesive ecosystem.

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

### Xonsh is Everywhere

Xonsh is designed to adapt seamlessly to any platform, enabling the same workflows to run seamlessly across macOS, Linux, Windows, so scripts, aliases, and tools behave consistently across different environments and package managers.

    $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/com.termux/usr/bin'] # Termux
    ['/tmp/.mount_x/usr/bin']    # AppImage
    ['/app/bin']                 # Flatpak
    $PATH = ['/my/own/path']

Learn more →

## Extensions

Extensions in the Xonsh ecosystem are called xontribs (short for “contributions”) — a set of tools and conventions for extending the functionality of xonsh.

pipeliner

Let your pipe lines from the standard output flow thru the Python code in the xonsh shell.

output-search

Get identifiers, paths, URLs and words from the previous command output and use them for the next command in the xonsh shell.

back2dir

Return to the most recently used directory when starting the xonsh shell.

argcomplete

Argcomplete support to tab completion of python and xonsh scripts in the xonsh shell.

More xontribs →