Skip to content

Latest commit

 

History

History
66 lines (44 loc) · 1.48 KB

README.md

File metadata and controls

66 lines (44 loc) · 1.48 KB

zx-snippets 1.03

Finally we can write bash scripts with javascript.

zx on github

Install zx

npm i -g zx
yarn global add zx

Available scripts

upgrade_node_lts.mjs

Keep your node lts version up-to-date! Checks if there is a new version, installs it and sets it as default. After that it reinstalls all global packages from the old version. Maybe I will make this a little bit more flexible.

create_headless_vm.mjs Create a new headless virtualbox virtual machine. Answer all the questions and vm is created. In the last question you can add all the additional parameters that were missing in the questions before.

Planned scripts

  • keep your sdk versions up-to-date
  • some stuff for homebrew
  • ...

Demo

Examples

Documentation

Documentation

Write your scripts in a file with .mjs extension in order to be able to use await on top level. If you prefer the .js extension, wrap your scripts in something like void async function () {...}().

Add the following shebang to the beginning of your zx scripts:

#!/usr/bin/env zx

Now you will be able to run your script like so:

chmod +x ./script.mjs
./script.mjs

Or via the zx executable:

zx ./script.mjs

When using zx via the executable or a shebang, all of the functions ($, cd, fetch, etc) are available straight away without any imports.