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

xonsh: add module and some shell integrations #5160

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

inmaldrerah
Copy link

@inmaldrerah inmaldrerah commented Mar 19, 2024

Description

Add a module for shell Xonsh and some shell integrations for it.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@XYenon for yazi integration
@jpteb for zoxide integration, as the latest editor, since it seems the original maintainer had left the community (sadly)

Do I also need to CC the maintainer of the xonsh package in nixpkgs?

@jpteb
Copy link
Contributor

jpteb commented Mar 27, 2024

Hi, I've finally had a look and the integration with zoxide looks good to me.

@inmaldrerah
Copy link
Author

Thanks. By the way, how can I initiate the tests? Should I ping someone or just wait for maintainer approval?

@inmaldrerah
Copy link
Author

Sorry, I forgot to use hm.maintainers. Should be fixed now.

@inmaldrerah
Copy link
Author

inmaldrerah commented Apr 2, 2024

Could any maintainer help with the approval please?

@XYenon
Copy link
Contributor

XYenon commented Apr 2, 2024

I'm not familiar with xonsh. But I have taken a look of the document, and I think it uses an alias instead of a init() function.

@inmaldrerah
Copy link
Author

I'm not familiar with xonsh. But I have taken a look of the document, and I think it uses an alias instead of a init() function.

Ah yes, Xonsh does use aliases to make a Pythonic function available as a Shell-like command, and that's why I set the field of aliases here.

In Xonsh, using def will make the function available directly as that name in a Pythonic manner. If ya(arg) is defined directly (without being wrapped by init()) and "ya" is set as an alias of the ya function (aliases["ya"] = ya), it will be available as both a shell-like command and a Pythonic function, and Xonsh will prefer the latter when only ya is typed and will print str(ya) rather than call ya([]).

The init() function is neither recognized nor directly called by Xonsh. Instead, it is called immediately after it is created, and then deled. In this way, the ya(args) function will stay inside the body of the init() function, and alias["ya"] will be a function inside a closure, making it impossible to directly call ya with ya(args), only possible through the shell alias, i.e. ya, or ya path/to/folder/or/file.

But I have to admit init is not a good name, as it might collide with other functions defined with that name. I'm going to change it to __yazi_init.

@inmaldrerah
Copy link
Author

Could anyone help with workflow approval?

modules/programs/yazi.nix Outdated Show resolved Hide resolved
@yajo yajo mentioned this pull request Jun 17, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants