{"id":16369647,"url":"https://github.com/dcsunset/batch-cmd","last_synced_at":"2026-02-25T06:37:56.130Z","repository":{"id":190005252,"uuid":"677201733","full_name":"DCsunset/batch-cmd","owner":"DCsunset","description":"Executing multiple commands in batches concurrently and easily","archived":false,"fork":false,"pushed_at":"2024-12-15T14:37:08.000Z","size":165,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-22T20:35:58.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DCsunset.png","metadata":{"files":{"readme":"README.org","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-11T01:53:42.000Z","updated_at":"2024-12-15T14:37:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d9e428a-2a2a-4fe0-b8f4-694dcb1a5f5c","html_url":"https://github.com/DCsunset/batch-cmd","commit_stats":{"total_commits":50,"total_committers":1,"mean_commits":50.0,"dds":0.0,"last_synced_commit":"02e571c8dae51707c276ec4cdcf811fd01e00a61"},"previous_names":["dcsunset/batch-cmd"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCsunset%2Fbatch-cmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCsunset%2Fbatch-cmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCsunset%2Fbatch-cmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DCsunset%2Fbatch-cmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DCsunset","download_url":"https://codeload.github.com/DCsunset/batch-cmd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231970940,"owners_count":18453928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T02:55:54.485Z","updated_at":"2025-10-28T18:12:01.477Z","avatar_url":"https://github.com/DCsunset.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"* batch-cmd\n\n# use $.svg to make it render as image\n[[https://npmjs.org/package/batch-cmd][https://badgen.net/npm/v/batch-cmd#.svg]]\n[[https://npmjs.org/package/batch-cmd][https://badgen.net/npm/types/batch-cmd#.svg]]\n\nExecuting multiple commands in batches concurrently.\nIt provides useful command-line tools and can also be imported as a library in JS (ESM).\n\n** Installation\n\nYou can install it directly from npm:\n\n#+begin_src shell\n  npm install batch-cmd\n#+end_src\n\n# TODO: uncomment this when NUR repo is added\n# This repo can also be installed by NUR if you are using Nix:\n\n# #+begin_src nix\n# environment.systemPackages = with pkgs; [\n#   nur.repos.dcsunset.batch-cmd\n# ];\n# #+end_src\n\n** Command-line Usage\n\nThis repo provides two tools, ~bcmd~ and ~bssh~.\nThe first one is used for running general shell commands,\nwhile the second one is more conveniently for running commands on remote machines via SSH.\n\nBoth tools will handle OS signals in the following way:\n\n- Upon receiving the first ~SIGINT~ / ~SIGTERM~: the program will send ~SIGTERM~ to all running commands and wait for them to stop.\n- Upon receiving the second  ~SIGINT~ / ~SIGTERM~: the program will send ~SIGKILL~ to force kill all running commands.\n- Upon receiving more than two ~SIGINT~ / ~SIGTERM~: the program itself will exit forcefully.\n\nBoth tools will pass input from ~stdin~ to ~stdin~ of all the commands.\nIt will also collect ~stdout~ / ~stderr~ from all commands and output in the ~stdout~ / ~stderr~,\nwith a prefix to distinguish them.\n\n*** bcmd\n\n#+begin_src shell\n  # running 3 commands with 3 variables (-- is used to separate options from command)\n  # variables can be used in the template command (must be quoted)\n  bcmd -v A B C -- \"echo {}\"\n  # multiple variables can be used for each command by specifying a separator\n  bcmd -v A:1 B:2 C:2 -s \":\" -- \"echo {0} {1}\"\n  # read variables from a file (can be combined with -v option)\n  bcmd -f vars.txt -- \"mkdir {0} \u0026\u0026 echo {0}\"\n  # pipe input to all commands\n  echo 'var' | bcmd -v A B C -- \"cat -\"\n#+end_src\n\nFor more usage, please see ~bcmd -h~.\n\n*** bssh\n\n~bssh~ is similar to ~bcmd~ but more convenient to run command on remote machines.\nThe first variable for each command must be the address of the remote machine.\n\n#+begin_src shell\n  # running 3 commands with 3 variables (-- is used to separate options from command)\n  # variables can be used in the template command (must be quoted)\n  bssh -v host1 host2 host3 -- \"ls\"\n  # multiple variables can be used for each command by specifying a separator\n  # note: the first argument is consumed internally using {0}, so other placeholders must be numbered as well\n  bssh -v host1:A host2:B -s \":\" -- \"echo {1}\"\n  # read variables from a file (can be combined with -v option)\n  bssh -f hosts.txt -v host3 host4 -- \"echo {0}\"\n  # pipe input to all commands\n  echo 'var' | bssh -v host1 host2 -- \"cat -\"\n#+end_src\n\nFor more usage, please see ~bssh -h~.\n\n** Library Usage\n\nThis repo also exports a JS (ESM) library (with type declarations).\nExample usage:\n\n#+begin_src js\n  import { CommandExecutor, runExecutor } from \"../src/lib.js\";\n\n  const executor = new CommandExecutor([\n    [\"a\", \"1\"],\n    [\"b\", \"2\"],\n    [\"c\", \"3\"]\n  ]);\n  await runExecutor(executor, \"echo From {0}: {1}\", \":\");\n#+end_src\n\n** Changelog\n\nSee [[https://github.com/DCsunset/batch-cmd/blob/main/CHANGELOG.md][CHANGELOG.md]].\n\n** License\n\nThis project is licensed under AGPL-3.0.\n\n#+begin_quote\nCopyright (C) 2023  DCsunset\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n#+end_quote\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcsunset%2Fbatch-cmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcsunset%2Fbatch-cmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcsunset%2Fbatch-cmd/lists"}