{"id":7803415,"url":"https://github.com/anki-code/xonsh-install","last_synced_at":"2025-03-21T08:31:20.850Z","repository":{"id":232928831,"uuid":"783414781","full_name":"anki-code/xonsh-install","owner":"anki-code","description":"Best way to install xonsh on Linux or macOS and using it as core shell. ","archived":false,"fork":false,"pushed_at":"2025-03-04T13:26:15.000Z","size":167,"stargazers_count":18,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T22:55:14.796Z","etag":null,"topics":["conda","mamba","micromamba","miniconda","xonsh","xonsh-dev","xontrib"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-07T20:22:42.000Z","updated_at":"2025-03-04T13:26:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0f5fd8b-8656-4d16-be20-4a6f98be6144","html_url":"https://github.com/anki-code/xonsh-install","commit_stats":null,"previous_names":["anki-code/xonsh-install"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxonsh-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/xonsh-install/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244765005,"owners_count":20506747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conda","mamba","micromamba","miniconda","xonsh","xonsh-dev","xontrib"],"created_at":"2024-04-12T07:01:13.863Z","updated_at":"2025-03-21T08:31:20.837Z","avatar_url":"https://github.com/anki-code.png","language":"Shell","funding_links":[],"categories":["Education materials"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\nBest way to install xonsh on macOS or Linux and using it as core shell.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e  \nIf you like the idea click ⭐ on the repo and \u003ca href=\"https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!\u0026url=https://github.com/anki-code/xonsh-install\" target=\"_blank\"\u003etweet\u003c/a\u003e.\n\u003c/p\u003e\n\n## Motivation\n\nXonsh 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](https://github.com/anki-code/xonsh-cheatsheet/).\n\nWhen 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 lightweight environment managers like `venv`, `pipx` or `rye` will not help with this and it's needed to use package managers that have ability to install isolated python invironment as core feature e.g. `miniconda`, `micromamba`.\n\n## mamba-install-xonsh\n\nThe `mamba-install-xonsh.sh` script creates independent python environment for xonsh using [mamba](https://mamba.readthedocs.io/) in `$TARGET_DIR` without affect any other things on the system. 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.\n\n**\u003cins\u003eInstall stable\u003c/ins\u003e**: the latest xonsh release with mostly tested python version:\n\n```xsh\nTARGET_DIR=$HOME/.local/xonsh-env PYTHON_VER=3.11 XONSH_VER='xonsh[full]\u003e=0.19.0' \\\n /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/anki-code/xonsh-install/main/mamba-install-xonsh.sh)\"\n```\n\n**\u003cins\u003eInstall the front line\u003c/ins\u003e**: xonsh from main git branch with stable python version (known issues: [#5166](https://github.com/xonsh/xonsh/issues/5166)):\n\n```xsh\nTARGET_DIR=$HOME/.local/xonsh-env PYTHON_VER=3.12 XONSH_VER='git+https://github.com/xonsh/xonsh#egg=xonsh[full]' \\\n /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/anki-code/xonsh-install/main/mamba-install-xonsh.sh)\"\n```\n\n**\u003cins\u003eInstall with stuff\u003c/ins\u003e**: preinstall and preload [xontribs](https://github.com/topics/xontrib) (good for ssh and as manual alternative to [xxh](https://github.com/xxh/xxh)):\n\n```xsh\nTARGET_DIR=$HOME/.local/xonsh-env PYTHON_VER=3.11 XONSH_VER='git+https://github.com/xonsh/xonsh#egg=xonsh[full]' \\\n PIP_INSTALL=\"uv xontrib-sh xontrib-jump-to-dir xontrib-dalias xontrib-pipeliner xontrib-whole-word-jumping\" \\\n XONSHRC=\"\\$XONSH_HISTORY_BACKEND = 'sqlite'; xontrib load -s sh jump_to_dir pipeliner whole_word_jumping dalias; \\$PROMPT = \\$PROMPT.replace('{prompt_end}', '\\n{prompt_end}')\" \\\n /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/anki-code/xonsh-install/main/mamba-install-xonsh.sh)\"\n```\n\n### Usage\n\nNow 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.\n\nAfter installation:\n* `xonsh` refers to `~/.local/xonsh-env/xbin/xonsh`.\n* `xpip` refers to `~/.local/xonsh-env/bin/python -m pip`.\n* You can run `source xmamba` to activate mamba. See below.\n\nAdditions:\n\n* `xbin-xonsh` is to run xonsh from xonsh-env if xonsh overwritten by `$PATH`.\n* `xbin-python` is to run python from xonsh-env.\n* Use executable script from xonsh-env:\n  * `xbin-hidden` is to list xonsh-env internal hidden `bin` directory. E.g. `xpip install lolcat \u0026\u0026 xbin-hidden # lolcat`.\n  * `xbin-add` is to add executer from hidden `bin` to visible `xbin`. E.g. `xbin-add lolcat`.\n  * `xbin-list` is to list visible `xbin` directory. E.g. `xbin-list # lolcat`.\n  * `xbin-del` is to delete executer from `xbin`. E.g. `xbin-del lolcat`. It will stay in `bin`.\n\n### Tips and tricks\n\n#### Using mamba from xonsh-env\n\nTo bind xonsh-env micromamba to `xmamba` alias run:\n```xsh\nsource xmamba\n```\nNow you can:\n```xsh\nxmamba activate base  # Env where xonsh was installed.\npip install lolcat  # Install `lolcat` into `base` env.\nxmamba deactivate\n\nxmamba create --name myenv python=3.12\nxmamba activate myenv\npip install lolcat  # Install `lolcat` into `myenv`.\nxmamba deactivate\n```\n\n#### Cleaning\n\nIf you have no plans to use `xmamba` [clean](https://fig.io/manual/mamba/clean) the disk space: \n\n```xsh\nsource xmamba\nxmamba clean -a\n```\n\n### Uninstall\n\nJust delete `$TARGET_DIR` e.g. `rm -rf ~/.local/xonsh-env/` by default.\n\n### Known issues\n\n#### Do not blindly use as a login shell\n\nWe do not recommend to use xonsh as a [login shell](https://linuxhandbook.com/login-shell/) if you are not feel you strong and experienced. Most tools are waiting that login shell is POSIX-compliant you can face with issues when some tool is trying to run POSIX-compatible commands in xonsh.\n\n#### `std::bad_alloc`\n\nIf you see `terminate called after throwing an instance of 'std::bad_alloc'` just delete the target directory (e.g. `rm -rf ~/.local/xonsh-env/`) and try to install again.\n\n## Another way to install xonsh\n\nIf you know how to install xonsh using another package manager - PR is welcome!\n\n## See also\n* [xonsh-cheatsheet](https://github.com/anki-code/xonsh-cheatsheet/tree/main) - Cheat sheet for xonsh shell with copy-pastable examples. The best doc for the new users. \n* [xonsh.AppImage](https://xon.sh/appimage.html) - 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxonsh-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Fxonsh-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxonsh-install/lists"}