I'm looking for a tool that can help me "compile" a shell script into a more compact file that can still be executed by a regular shell interpreter. Ideally, I want to reduce the size by removing all indentation, deleting comments, renaming variables and functions to shorter names, and possibly using aliases for commonly used code snippets. So far, I haven't found anything beyond basic compression tools like .zip.
5 Answers
I’m not great at coding, but when I'm done with my script, I just delete it using `rm -rf script`. It's the ultimate compression!
You could try to convert your script to Rust and compile it. That might help with size and performance. Plus, asking a language model can point you in the right direction for that.
Why do you need to compress your script so much? The difference in size is usually pretty negligible, even a couple of KB doesn't make a huge impact on most systems.
What you're really after is a minifier instead of a standard compressor. Check out this GitHub resource: https://github.com/Zuzzuc/Bash-minifier. It should do what you need for minimizing your shell script.
Minifying makes sense! I hadn't thought of that term. Thanks for the tip!

That's an interesting idea! Rust's performance could definitely help if you're trying to optimize for size.