Best way to install xonsh on macOS or Linux and using it as core shell.
If you like the idea click ⭐ on the repo and tweet.
Xonsh is a Python-based shell, and to run xonsh you must have Python installed. The Python version and its packages can be installed and located anywhere and when you execute import
or any other Python code during a xonsh session, it will be executed in the Python environment that was used to run the current instance of xonsh. You must have good knowledge of this process after reading xonsh-cheatsheet.
When xonsh becomes a core shell it's needed to keep python environment with xonsh stable, predictable and independent of any changes in the system. The environment managers like venv
, pipx
or rye
will not help with this.
The mamba-install-xonsh.sh
script creates independent python environment for xonsh using mamba. It's isolated xonsh-specific environment that can't be affected by upgrading the system packages, python version and other experiments around environments. You can use xpip
and xmamba
to install packages into this environment intentionally.
Install stable: the latest xonsh release with mostly tested python version:
TARGET_DIR=$HOME/.local/xonsh-env PYTHON_VER=3.11 XONSH_VER='xonsh[full]' \
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/anki-code/xonsh-install/main/mamba-install-xonsh.sh)"
Install the front line: xonsh from main git branch with latest python version:
TARGET_DIR=$HOME/.local/xonsh-env PYTHON_VER=3.12 XONSH_VER='git+https://github.com/xonsh/xonsh#egg=xonsh[full]' \
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/anki-code/xonsh-install/main/mamba-install-xonsh.sh)"
Known issues of latest python version: #5166.
Now forget about the cases where manipulations around python and packages break the shell unintended. Use pip
, brew
and other package managers without corrupting xonsh-env.
After installation:
xonsh
refers to~/.local/xonsh-env/xbin/xonsh
.xmamba
refers to~/.local/xonsh-env/xbin/xmamba
.xpip
refers to~/.local/xonsh-env/bin/python -m pip
.
xbin-xonsh
is to run xonsh from xonsh-env if xonsh overwritten by$PATH
.xbin-python
is to run python from xonsh-env.- Use executable script from xonsh-env:
xbin-list-bin
is to list internalbin
directory in xonsh-env. E.g. youxpip install lolcat
.xbin-add
is to add executer frombin
toxbin
. E.g.xbin-add lolcat
.xbin-list
is to listxbin
directory. E.g. you check thatlolcat
is there.xbin-del
is to delete executer fromxbin
. E.g. removelolcat
fromxbin
.
If you have no plans to use xmamba
clean the disk space: xmamba clean -a
.
If you know how to install xonsh using another package manager PR is welcome!
- xonsh-cheatsheet - Cheat sheet for xonsh shell with copy-pastable examples. The best doc for the new users.
- xonsh.AppImage - one executable file which contains both xonsh and Python. AppImage allows xonsh to be run on any AppImage supported Linux distribution without installation or root access.