LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

zx

Note: This post is over 5 years old. The information may be outdated.

A tool for writing better scripts by Google - zx. I usually choose to write a Python or Deno script instead of a shell script for more convenience. I found this tool is so great, helping to write the script quickly. It would help if you tried it too.

Refer to the Git repo here for the detailed document: https://github.com/google/zx

Some examples

backup-github.mjs

#!/usr/bin/env zx

let username = await question('What is your GitHub username? ')
let token = await question('Do you have GitHub token in env? ', {
  choices: Object.keys(process.env),
})

let headers = {}
if (process.env[token]) {
  headers = {
    Authorization: `token ${process.env[token]}`,
  }
}
let res = await fetch(`https://api.github.com/users/${username}/repos`, {
  headers,
})
let data = await res.json()
let urls = data.map((x) => x.git_url)

await $`mkdir -p backups`
cd('./backups')

await Promise.all(urls.map((url) => $`git clone ${url}`))
zx ./backup-github.mjs

External files

zx https://gist.githubusercontent.com/duyet/04fe68cc1ce7c82360354a90824a5edd/raw/6e4dbcd74688fd492cbbb1f746e501f77c3f93d0/wttr.mjs

Aug 28, 2021·5 years ago
|Productivity|
Data EngineeringLinux
|Edit|

Related Posts

Uptime with GitHub Actions

Hey, I just found this tool, so incredibly clever that it uses Github Actions for uptime monitor and status page.

Sep 20, 2021·4 years ago
Read more

From Docker to Podman on MacOS

I'm looking for some of alternatives for Docker. Currently, there are a few of container technologies which are Docker’s most direct competitors, such as rkt, Podman, containerd, ...

Sep 5, 2021·4 years ago
Read more

Bitbucket Pipelines Notes

Bitbucket Pipelines document is fragmented everywhere. It always makes me search for a while every time I write a new one for CI/CD. So I'll make a few notes here.

Aug 27, 2021·5 years ago
Read more

My Neovim Setup in 2023

It's been years since I first started using neovim and I've been updating it regularly ever since.

Sep 4, 2023·2 years ago
Read more
On this page
  • backup-github.mjs
  • External files
On this page
  • backup-github.mjs
  • External files