Skip to content

anki-code/xonsh-install

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 

Repository files navigation

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.

Motivation

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.

mamba-install-xonsh

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.

Usage

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.

Additions

  • 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 internal bin directory in xonsh-env. E.g. you xpip install lolcat.
    • xbin-add is to add executer from bin to xbin. E.g. xbin-add lolcat.
    • xbin-list is to list xbin directory. E.g. you check that lolcat is there.
    • xbin-del is to delete executer from xbin. E.g. remove lolcat from xbin.

Tips and tricks

If you have no plans to use xmamba clean the disk space: xmamba clean -a.

Another way to install xonsh

If you know how to install xonsh using another package manager PR is welcome!

See also

  • 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.

About

Best way to install xonsh on Linux or macOS and using it as core shell.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages