$linuxjunkies
>

xonsh(1)

xonsh is a Python-powered shell that combines the best of Unix shells and Python scripting.

UbuntuDebianFedoraArch

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

FlagWhat it does
-c, --commandRun the specified command string and exit
-i, --interactiveForce interactive mode even when piped or executing scripts
--no-rcSkip loading .xonshrc initialization file
-v, --versionDisplay xonsh version and exit
--no-auto-cdDisable automatic directory change with bare directory names
-l, --loginExecute as a login shell, loading profile scripts
--debugEnable debug mode with verbose output for troubleshooting
-D, --no-detachDo not detach subprocess; useful for job control debugging

Examples

Start an interactive xonsh shell prompt

xonsh

Execute 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.xsh

Execute 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-rc

Execute a command substitution using shell syntax within xonsh

xonsh -c "$(which python3) --version"

Related commands