News for hackers. Stuff that matters.
Re:The Xonsh Python Shell by traverseda on Monday October 12, 2020 @03:40PM (#24758577)
Put this in my `~./xonshrc` a while ago

    from pathlib import Path
    from xonsh.events import events
    class CwdPath(type(Path())):
        def __iter__(self):
            return self.iterdir()

    $cwd = CwdPath.cwd()

    @events.on_chdir
    def set_cwd(olddir, newdir, **kw):
        $cwd = CwdPath(newdir)
It's really nice being to do

    for f in $cwd:
        echo @(f.name)
or equivalent, especially with python's glob syntax

    for f in $cwd.glob("**/*.png"):
        #Do a thing
Overall I've been really enjoying xonsh, now that I've got the hand of it.

There are no comments on this comment yet.