Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add xontext to builtin aliases #5400

Open
anki-code opened this issue May 8, 2024 · 0 comments
Open

Feature: add xontext to builtin aliases #5400

anki-code opened this issue May 8, 2024 · 0 comments

Comments

@anki-code
Copy link
Member

anki-code commented May 8, 2024

I found that xc from xontrib-rc-awesome is very useful alias:

from shutil import which as _which

# Alias to get Xonsh Context.
# Read more: https://github.com/anki-code/xonsh-cheatsheet/blob/main/README.md#install-xonsh-with-package-and-environment-management-system
@aliases.register("xc")
def _alias_xc():
    """Get xonsh context."""    
    print('xpython:', imp.sys.executable, '#', $(@(imp.sys.executable) -V).strip())
    print('xpip:', $(which xpip).strip())  # xpip - xonsh's builtin to install packages in current session xonsh environment.
    print('')
    print('xonsh:', $(which xonsh))
    print('python:', $(which python), '#', $(python -V).strip())
    print('pip:', $(which pip))
    if _which('pytest'):
        print('pytest:', $(which pytest))
    print('')
    envs = ['CONDA_DEFAULT_ENV']
    for ev in envs:
        if (val := __xonsh__.env.get(ev)):
            print(f'{ev}:', val)

It will be grate to have xontext alias:

xontext
# [Current xonsh session]
# xpython: /Users/pc/.local/xonsh-env/bin/python # Python 3.12.2
# xpip: /Users/pc/.local/xonsh-env/bin/python -m pip
#
# [Current commands environment]
# xonsh: /Users/pc/.local/xonsh-env/xbin/xonsh  # https://github.com/anki-code/xonsh-install
# python: /opt/homebrew/bin/python # Python 3.11.6
# pip: /opt/homebrew/bin/pip

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant