r/lua • u/no_brains101 • May 03 '25
`shelua`: use your shell as real lua code!
Announcing: https://github.com/BirdeeHub/shelua
It lets you do this:
print(sh.ls '/bin' : grep "$filter" : wc '-l')
or
print(sh.find('/usr/bin', '-type', 'f', '-executable') : grep 'python' : wc '-l')
Some of you may have heard of https://github.com/zserge/luash before.
I heard about it last week.
"What a beautiful little library!" I thought to myself, and went to try it out.
That's when it hit me. "I'm sorry, it does WHAT to _G?!?! I can't import this anywhere!"
I also found out error codes don't work before 5.2. And that it can't do real pipes. To be fair, it seemed like real pipes could not be done at first to me as well.
I look at the repo. Last push, 9 years ago. This was made for me. A cool experiment neglected.
Within the evening, I had it localized to the variable it came from, without losing its ergonomics, and fixed error codes prior to 5.2 and added some useful settings not there previously.
But I was not satisfied. I wanted REAL pipes. The ones in bash where all the commands start at the same time.
And its kinda fun... I might want to use it with another shell...
Well, a few days later, now you can enable proper pipes, and you can even make it work with any shell with just a bit of effort.
It is still tiny, and a single file.
I am pleased to be able to announce to you all an exciting and far more modular iteration of the idea luash brought to us. One you can include in other projects or even your neovim configuration without fear of messing it up. I have really enjoyed it so far.
View all comments
Show parent comment
2
u/no_brains101 May 03 '25 edited May 03 '25
oh, filter is a variable defined in lua. MB if that wasnt clear.
I pulled it from the readme where it is more clear
OH hang on I know how to make it make more sense and only add 3 chars 1s+
Theres an escape_args setting but by default it does not escape.