{"id":15792695,"url":"https://github.com/nfour/unishell","last_synced_at":"2026-02-11T07:03:05.270Z","repository":{"id":41796992,"uuid":"176674303","full_name":"nfour/unishell","owner":"nfour","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-03T18:13:37.000Z","size":765,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-31T12:11:11.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nfour.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-20T07:02:24.000Z","updated_at":"2019-09-12T09:47:55.000Z","dependencies_parsed_at":"2023-02-01T08:31:42.134Z","dependency_job_id":null,"html_url":"https://github.com/nfour/unishell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nfour/unishell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Funishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Funishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Funishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Funishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfour","download_url":"https://codeload.github.com/nfour/unishell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Funishell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29329492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-04T23:02:55.460Z","updated_at":"2026-02-11T07:03:05.255Z","avatar_url":"https://github.com/nfour.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unishell\n\n- [Why](#why)\n- [Examples](#examples)\n\n## Why\n\nGot tired of having to pick and choose which library to interact with the CLI. This attempts to unify it.\n\n**Goals**:\n- Be as terse and as close to a bash script as reasonable\n- Normalize local and remote CLI interactions\n\n**Usage examples**:\n- Regular CLI interaction with a terser interface\n- Deployment scripts for remote SSH targets\n\n\n## Examples\n\n```ts\nimport { Unishell } from 'unishell';\n\nconst unishell = new Unishell({ /* global options */ });\n\n/** Produces a `ssh2` powered client */\nconst ssh = unishell.ssh({\n  host: 'localhost',\n  user: 'foo',\n  identity: '',\n});\n\n/** Produces a local `execa` powered client */\nconst local = unishell.local({\n  cwd: __dirname,\n});\n\nawait ssh.connect();\n\nconst r1 = await ssh.exec('echo foo');\n\nr1; // \"foo\"\n\nconst r2 = await ssh.exec('echo foo').details();\n\nr2.output; // \"foo\"\n\nawait ssh.exec('echo foo').pipe({ stdout: process.stdout });\n\nconst r3 = ssh.exec('echo foo').pipe(process);\n\nr3.on;\n\nconst r4 = await r3;\n\nr4;\n\nconst r5 = await ssh.exec('notARealCommand');\n\nr5; // \"command not found: notARealCommand\"\n\ntry {\n  await ssh.exec('notARealCommand').reject().details();\n} catch (r6) {\n  r6;\n  // { stdout: \"\", stderr: \"command not found: notARealCommand\", exitCode: 127, ... }\n}\n\nconst r7 = await ssh.shell(async (exec) =\u003e {\n  exec('').reject;\n  exec('').details;\n  exec('').pipe;\n  exec('').then;\n});\n\nr7;\n\nconst r8 = await ssh.exec('echo foo').reject(); // doesnt actually reject, as `echo` wont error\n\nr8; // \"foo\"\n\nawait ssh.shell(async (exec) =\u003e {\n  await exec('echo foo');\n})\n  .pipe(process);\n\nconst sessionStream = ssh.shell(async (exec) =\u003e {\n  await exec('echo foo');\n  await exec('exit');\n});\n\n/** Piping the parent node CLI input into the ssh session's stdin */\nprocess.stdin.pipe(sessionStream.stdin);\n\n/** Piping the ssh session's stdout and stderr into the parent node process */\nsessionStream.pipe(process);\n\nawait sessionStream; // Shell session is over\n\nawait local.connect();\n\n/** Run commands locally */\nawait local.shell(async (exec) =\u003e {\n  const r10 = await exec('ls -lsah').details();\n\n  r10.cmd;\n});\n\n/** Access the `ssh2` Client to do advanced operations */\nconst ssh2 = ssh.client();\n\nssh2.forwardIn;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfour%2Funishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfour%2Funishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfour%2Funishell/lists"}