Admittedly much more complicated than necessary, but it's pretty full featured.
first line constructs a filename for the new script from a generated 10 character random hash and prepends "nscript" and a user provided name.
The second line writes out the shebang and a few oft used bash flags, makes the file executable and opens in in my editor (Helix in my case).
The third line is just a shortened alias for the function.
Use && to use multiple commands one after the other, don't use ;.
&& means execute if the command before ended successfully
|| means execute if the commnad before failed
; just means execute the command - no matter if succeeded or failed
My dude, thanks for this. I've been using && for a long time now but never knew the rest, I'm still pretty new to linux comparatively.
touch file && chmod +x file
You could append the chmod command with && but that's probably not what you wanted.
You mean like
touch file && chmod +x file
?Wrap it up folks, we're done here.