Easier Shell Scripting with ZX (first look)

  Рет қаралды 8,305

Andrew Burgess

Andrew Burgess

Күн бұрын

Пікірлер: 31
@zeenuexe8362
@zeenuexe8362 Жыл бұрын
As someone who doesn't know how to do anything complex in bash, this is fantastic. i will try it out.
@ashwinbhargava3011
@ashwinbhargava3011 Жыл бұрын
As a web developer, I want to give Google a kiss. I literally hate Bash's syntax because I always had to Google everything every time I wanted to script something. And when I started using Fish, POSIX compliance was a headache. I was thinking of creating a wrapper module for Node.js exactly like this. Great video btw.
@karamuto1565
@karamuto1565 Жыл бұрын
Really interesting maybe I will pitch this to my team in the new year as we only have maybe 3 people that can actually handle the more complex shell scripts we have.
@nithinrajendran3091
@nithinrajendran3091 Жыл бұрын
peter parker in the alternate universe
@karixening
@karixening Жыл бұрын
Check out the deno package called rush. Just a prototype, but similar concept. I think Deno is really good for scripting since you don't have to worry about installing any dependencies.
@andrew-burgess
@andrew-burgess Жыл бұрын
Thanks, I’ll check it out!
@RahulGupta-vw8jr
@RahulGupta-vw8jr Жыл бұрын
While this is cool, the utility of bash commands are that they can be run on any system with the same OS. Using ZX will create a dependency on having node installed and this package installed. Now you need to know both bash and JS use this. Why not just use execSync package is JS? But if you are using it for personal project or you are the main mainter of a project this make sense.
@PaulJohnLeonard
@PaulJohnLeonard Жыл бұрын
I currently use execSync. I will probably switch to zx because it looks like the code will have less boiler plate and be easier to read. I dont mind the one off devop dependancy.
@christianalares
@christianalares Жыл бұрын
Have you managed to make this work with TypeScript? I would like to rewrite a CLI i made before but with zx. But if I'm not able to do it with TS it's not worth it imo.
@avi7278
@avi7278 Жыл бұрын
Does not seem like the compiler could handle it. Those literals prefixed with $ are not valid syntax, are they?
@loic.bertrand
@loic.bertrand Жыл бұрын
​@@avi7278it is valid JS and TS syntax, it's called a Tagged Templated Literal 🙂 here '$' is tag function which processes the template literal as well as its "dynamic" values (${...} parts in the template)
@SuperQuwertz
@SuperQuwertz 9 ай бұрын
You can use bun to run the script without transpiling it
@SuperQuwertz
@SuperQuwertz 9 ай бұрын
Or just use JSDocs Or transpile it (which isnt that nice imo)
@volodymyrvorona2250
@volodymyrvorona2250 Жыл бұрын
Another great video. Thank you!
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 Жыл бұрын
It s a great idea, I also start using rb.
@starseven4736
@starseven4736 Жыл бұрын
babashka is awesome way to script tooo
@HyperFocusMarshmallow
@HyperFocusMarshmallow Жыл бұрын
Looks nice.
@irlshrek
@irlshrek Жыл бұрын
dude, awesome find!
@replikvltyoutube3727
@replikvltyoutube3727 Жыл бұрын
As much as it looks nice, it seems to overly complicate things
@kris10an64
@kris10an64 Жыл бұрын
How exactly?
@jaysistar2711
@jaysistar2711 Жыл бұрын
No, I've been doing this sort of thing with Jake, a Make-like task runner with tasks written in JavaScript, and this greatly simplifies things.
@allisondealmeida
@allisondealmeida Жыл бұрын
are you using neovim?
@andrew-burgess
@andrew-burgess Жыл бұрын
I am! More about my setup here: shaky.sh/tools/
@sck3570
@sck3570 Жыл бұрын
that's dope 👌
@acquite
@acquite Жыл бұрын
i wrote my own implementation without knowing about this.. thanks for allowing me to discover it now. prior to this i was using the exec function from node:child-process as follows. it very much does the same thing that this is doing, just custom the following is an example of how it was written and how it can be used ```ts import { exec, ExecException } from 'child_process'; class Shell { static async run(command: string = 'ls', after = (stderr: ExecException | null, stdout: string): void => {}): Promise { return await new Promise((resolve): void => { exec(command, (stderr, stdout): void => { after(stderr, stdout); resolve(stdout); }); }); } } await Shell.run(`Echo "Hello World!"`, (_, stdout) => process.stdout.write(stdout)) const fonts = await Shell.run(`ls ./Fonts`) ``` this works fine but it requires some know-how of how promises work and how to wrap exec like this. overall zx makes this easier. thank you again!
@Fullflexno
@Fullflexno Жыл бұрын
Supercool +1 sub!
@voidmind
@voidmind Жыл бұрын
You kind of look like Linus Torvalds when he was young
@salman0ansari
@salman0ansari Жыл бұрын
cool ✌🏻
@ankanroy2931
@ankanroy2931 Жыл бұрын
nop, if i had to use this might just use python
@andrew-burgess
@andrew-burgess Жыл бұрын
Fair enough! I don’t know much python, is there a good way to get the output of shell commands, or is there just a better way to do it?
@twothreeoneoneseventwoonefour5
@twothreeoneoneseventwoonefour5 Жыл бұрын
@@andrew-burgess yes there are a lot of utils in python to interact with the shell and it is pretty easy and straightforward. subprocess, shutil is often good enough for most tasks though to get only output iirc(didnt use python for some time) there was subprocess.check_output or something like that. I used it to automate some stuff, getting output from ffprobe and feeding it to ffmpeg for example. subprocess have both sync and async procesd spawn, and as I said above can also get output of a command or a cli program easily
5 Terrific Git Commit Tips
8:24
Andrew Burgess
Рет қаралды 8 М.
Rust for TypeScript Developers
11:52
Andrew Burgess
Рет қаралды 53 М.
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Yay😃 Let's make a Cute Handbag for me 👜 #diycrafts #shorts
00:33
LearnToon - Learn & Play
Рет қаралды 117 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 126 МЛН
Write beautiful shell scripts with Gum! [Terminal Velocity 4]
13:23
Andrew Burgess
Рет қаралды 22 М.
Creating Command Line Menus with Shell Scripts
14:09
theurbanpenguin
Рет қаралды 82 М.
Bun shell на замену bash-скриптам
10:35
PurpleSchool | Anton Larichev
Рет қаралды 6 М.
Code Review: Google’s zx (write better shell scripts)
17:01
Harry Wolff
Рет қаралды 4,6 М.
How To Create A "Proper" CLI With Shell And Charm Gum
14:45
DevOps Toolkit
Рет қаралды 12 М.
any vs unknown vs never: TypeScript demystified
8:01
Andrew Burgess
Рет қаралды 24 М.
Function Overloading in TypeScript (I was wrong)
10:24
Andrew Burgess
Рет қаралды 14 М.
How to put Bash Scripts on the Web
15:02
Mark McNally
Рет қаралды 6 М.
Shell Ninja: Mastering the Art of Shell Scripting | Roland Huß
58:48
DevOps Conference
Рет қаралды 24 М.
Command Lines Scripts in JavaScript (or any language!)
8:18
Andrew Burgess
Рет қаралды 4,8 М.
Players push long pins through a cardboard box attempting to pop the balloon!
00:31