vsolina / mipyshell

MicroPython based imitation of a POSIX shell that supports line completion, history, basic threading (developed on ESP32 and ESP8266, probably works on other boards)
MIT License
43 stars 3 forks source link

Feature-request: minified copy of all files #2

Open gitcnd opened 8 months ago

gitcnd commented 8 months ago

Loving this amazing set of tools.

It takes up half the space if "compressed" though - all the default options here work fine for me: https://python-minifier.com/

Maybe create a subfolder "min" and throw all the lib and bin stuff in there? (You may want/need to add copyright and attribution back into the minified versions of course)

gitcnd commented 8 months ago

If anyone wants the minified versions; they are here: https://github.com/NoosaHydro/2.4inch_ESP32-2432S024/tree/main/cnd-micropython/lib

vsolina commented 8 months ago

Totally awesome! Thank you for minifying the source files. I guess I could add an optional build stage script to the repo.

Another good option for minimising flash and ram usage (also for some performance gains) is to compile the .py source files into .mpy: https://docs.micropython.org/en/latest/reference/mpyfiles.html But these are micropython version specific, so we'd need a set of built files - one for each version. Best solution would be to introduce a kind of micro package manager (apt, yum) running on ESP32 that would fetch the latest compatible version from a repository; likely utilizing upip - but another thin layer on top of it would be needed. [I intended to do this, but did not have time yet]

And obviously, if you do have spare flash available on you MCU, the cool thing about having the source files there is you can edit them directly. This becomes especially useful when using WebEditor and Shell together, debugging both at the same time on the device itself 😂

gitcnd commented 8 months ago

flash block size is 4k, and the vast majority of python things I'm messing with are already less than that without being minified...

the minify is already quite effective - the minimal extra gain for the .mpy headache doesn't seem worthwhile presently

gitcnd commented 3 weeks ago

I wrote a circuitpython port of this amazing tool - it might be worth updating your "Readme" so anyone on CircuitPython can use a similar tool to yours? https://github.com/gitcnd/cpy_shell

I attempted to get your micropython stuff working over there, but there's way too many major differences.

I've added support for pipes, I/O redirection, and multiple simultaneous streams (like sockets for telnet, serial for rs232, hardware for USB keyboards and LCD screens, websockets, etc etc ... so your board is going to "just work" no matter how you connect to it.

I also added environment variables and bash history saving to a file and store everything possible outside the code so there's max room left for everything else (my shell uses 9k) and I added the "!" command and intelligent up/down arrow history retrieval and tab completion too.

Example: pic_2024-06-28_03 05 47_706

so far includes: cat cd clear cls cp curl date df echo free help history ls man mkdir mv ping pwd reboot rm rmdir sleep sort test touch uptime wc wget which