4 ms·
Put this in my `~./xonshrc` a while ago from pathlib import Path from xonsh.events import events class CwdPath(type(Path())): def __iter__(
by traverseda 6y ago
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.