jaraco / cmdix

Fork of https://launchpad.net/pycoreutils
MIT License
27 stars 1 forks source link

How would I use cmdix in Xonsh? #8

Closed tahir-hassan closed 2 years ago

tahir-hassan commented 2 years ago

Hi

How would I go about using this in Xonsh to provide me with pure python implementations of ls, cat etc?

I take it the first step is to do pip install cmdix, but then after that how would I populate the aliases of Xonsh?

jaraco commented 2 years ago

Installation and use of cmdix is independent of xonsh, except that they share the same base programming language and could in theory share the same installation environment.

cmdix defines console scripts for each command, meaning that when pip installs cmdix, it will create those console scripts (for ls, cat, etc.).

The thing that a user needs to do to make those scripts usable is to include the scripts path on the execution path, and unfortunately, there's no one best way to do that. I'll recommend a couple of options:

pipx

Install and configure pipx per its guidance, then pipx install cmdix. pipx ensurepath will handle configuring the path.

user libs

Install cmdix to the user's local environment. pip install --user cmdix. Then ensure that the scripts directory is on the PATH (i.e. ~/AppData/Roaming/Python/Python310/Scripts) (pip will advise how to do so).

manual venv

Create your own virtualenv, either using virtualenv or python -m venv. For example:

python -m venv ~/AppData/Roaming/myvenvs/cmdix
~/AppData/Roaming/myvenvs/cmdix/Scripts/pip install cmdix

Then add that Scripts directory to the PATH.


If the commands are available in powershell or cmd.exe, they'll probably be available in powershell as well.

Let me know how it goes. I'll probably take the guidance above and publish it in the readme.

tahir-hassan commented 2 years ago

Hi, within Xonsh, you have xpip which calls pip. So I just did xpip install cmdix and that was all I needed to do. The Scripts folder is already included on PATH, so there is nothing to do there.

Thanks 👍