51 points · by benrutter · 3y ago · 25 comments
Disclaimer: I know about xonsh and love it (if you haven't heard of it, google it). This project is more pure python and less python and bash interacting - see the readme for more details.
~/me $_ x = files('Music')
~/me $_ for item in x:
> if 'Rick Astley' not in x['name']:
> delete(x['path'])
Shouldn’t that be: ~/me $_ x = files('Music')
~/me $_ for item in x:
> if 'Rick Astley' not in item['name']:
> delete(item['path'])
? for file in ls:
if file.is_mount():
try: fusermount -u @(file)
except: print(f"Couldn't unmount {file}")
Or more complicated stuff involving piping actual live python objects around. Xonsh is great, but the lack of what you're calling "super commands" does limit things a fair bit.Right now I can do similar stuff, but I often end up doing horrible things like
for file in $(ls).split("\n"):
file=Path(file)
which is not nearly as elegant, especially for more complicated stuff. Lots of places for issues to sneak in, like I'm pretty sure that splitting the output of ls like I did there gives me an extra null directory at the end of the output, not an issue here but it is one more spot for bugs to sneak in.Of course the other problem with these "super commands" is that they all have to exist in your master shell process. I wonder if you could use something like RPyC to have live python objects that are fully interactable but which live in other processes.
Really cool idea about separate processes- I guess since the shell is its own thing, there's no reason you couldn't write an interpreter in a non-GIL language (like rust or c++) even if the commands where Python. That'd free you up to spawn subprocesses and shells to your heart's content!
pyxargs --py "print('{}') if os.path.ismount('{}') else ''" | pyxargs -m stdin fusermount -u {}
[1] https://github.com/elesiuta/pyxargs roll 1d20
You rolled an 18
roll goblin.attacks.shortsword
You rolled an 4 on 1d6.
apply roll goblin.attacks.shortsword to character.hp
The other part will be that it'll let me connect into a foundry instance and have the chat/rolls show up on my terminal.I’ve found most of the alternatives have a high (for my use case) learning curve. For real debugging I use VSCode but it’s nice to be able to quickly throw breakpoints around.
It's a really dumb solution and can work in any language/environment, so I like it.