xonsh(1)
xonsh is a Python-powered shell that combines the best of Unix shells and Python scripting.
Synopsis
xonsh [OPTIONS] [FILE] [ARGS...]Description
xonsh is a cross-platform shell language and command prompt based on Python. It allows you to seamlessly mix shell commands with Python code, using Python's syntax and powerful standard library directly in your shell environment.
xonsh supports standard Unix shell operations like piping, redirection, and job control, while adding Python expressions, variables, and control flow. It works on Linux, macOS, and Windows, making it a versatile choice for system administrators and developers.
Common options
| Flag | What it does |
|---|---|
-c, --command | Run the specified command string and exit |
-i, --interactive | Force interactive mode even when piped or executing scripts |
--no-rc | Skip loading .xonshrc initialization file |
-v, --version | Display xonsh version and exit |
--no-auto-cd | Disable automatic directory change with bare directory names |
-l, --login | Execute as a login shell, loading profile scripts |
--debug | Enable debug mode with verbose output for troubleshooting |
-D, --no-detach | Do not detach subprocess; useful for job control debugging |
Examples
Start an interactive xonsh shell prompt
xonshExecute a Python statement directly and exit
xonsh -c "import os; print(os.getcwd())"Run a xonsh script file (similar to running a shell script)
xonsh myscript.xshExecute shell command with piping in xonsh
xonsh -c "ls -la | grep '.txt'"Use Python loop syntax with shell commands via @() syntax
xonsh -c "for i in range(5): echo @(i)"Start xonsh without loading .xonshrc configuration file
xonsh --no-rcExecute a command substitution using shell syntax within xonsh
xonsh -c "$(which python3) --version"