{"id":13701478,"url":"https://github.com/rse/stmux","last_synced_at":"2025-04-11T22:30:14.174Z","repository":{"id":38326019,"uuid":"88426985","full_name":"rse/stmux","owner":"rse","description":"Simple Terminal Multiplexer for Node.js Environments","archived":false,"fork":false,"pushed_at":"2024-09-15T15:33:39.000Z","size":1592,"stargazers_count":518,"open_issues_count":7,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-06T00:43:02.428Z","etag":null,"topics":["multiplexer","node","npm","script","simple","terminal"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/stmux","language":"JavaScript","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/rse.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-16T16:16:21.000Z","updated_at":"2025-03-19T08:22:16.000Z","dependencies_parsed_at":"2024-02-04T16:19:53.259Z","dependency_job_id":"189579d3-ea21-468c-aec7-47a00af3ecd8","html_url":"https://github.com/rse/stmux","commit_stats":{"total_commits":258,"total_committers":2,"mean_commits":129.0,"dds":0.003875968992248069,"last_synced_commit":"0e9eb233e1310c55cb9603896a65da1bf6ecd801"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fstmux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fstmux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fstmux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fstmux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rse","download_url":"https://codeload.github.com/rse/stmux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247735553,"owners_count":20987468,"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":["multiplexer","node","npm","script","simple","terminal"],"created_at":"2024-08-02T20:01:41.469Z","updated_at":"2025-04-11T22:30:14.148Z","avatar_url":"https://github.com/rse.png","language":"JavaScript","readme":"\nstmux\n=====\n\n**Simple Terminal Multiplexing for Node Environments**\n\n\u003cp/\u003e\n\u003cimg src=\"https://nodei.co/npm/stmux.png?downloads=true\u0026stars=true\" alt=\"\"/\u003e\n\n\u003cp/\u003e\n\u003cimg src=\"https://david-dm.org/rse/stmux.png\" alt=\"\"/\u003e\n\nAbstract\n--------\n\nThis is a simple terminal multiplexing utility for Node.js\nenvironments. It is inspired by the awesome and unreachable\n[tmux](https://tmux.github.io/) native Unix utility. The stmux utility\nis intended to provide just a very tiny subset of the original\n[tmux](https://tmux.github.io/) functionality, but in a portable way for\nbare Node.js environments and with some special features for application\nbuild environments. Most notably, stmux has a built-time error\ndetection and notification feature, can automatically restart terminated commands,\nand can automatically close or wait after all spawned commands have\nsuccessfully or unsuccessfully terminated.\n\nInternally, stmux is based on the awesome\n[Blessed](https://github.com/chjj/blessed) screen rendering environment\nand emulates full XTerm-compatible pseudo-terminals\nto the spawned programs with the help of [Blessed XTerm](https://github.com/rse/blessed-xterm)\nand the underlying [XTerm.js](http://xtermjs.org) terminal rendering\nand [node-pty](https://github.com/Tyriar/node-pty) pseudo-terminal\nintegration modules.\n\nExample\n-------\n\nThe following command...\n\n```\n$ stmux -- [ [ -s 1/3 bash .. vim ] : mc ]\n```\n\n...leads to the following particular terminal multiplexing environment,\nwhere GNU bash, Vim and Midnight Commander are running side-by-side\ninside their own XTerm emulating terminal widget (and, just for fun,\n`CTRL+a` `?` was pressed to open up the stmux help window):\n\n![stmux usage](etc/screenshot1.png)\n\nIntention\n---------\n\nThis utility is primarily intended to be used from within a\n`package.json` `script` to easily side-by-side run various NPM-based\ncommands in a Node.js build-time environment. Sample `package.json`\nentries from a top-level NPM-based project follows, which on `npm run\ndev` allows one to conveniently run the commands of two sub-projects.\nFirst, the build-time of the frontend user interface (UI) project.\nSecond, the build-time of the backend server (SV) project. Third, the\nrun-time of the backend server project.\n\n```js\n{\n    ...\n    \"dependencies\": {\n        \"stmux\":      \"*\"\n    },\n    \"scripts\": {\n        \"install\":    \"npm run install:ui \u0026\u0026 npm run install:sv\",\n        \"install:ui\": \"cd ui \u0026\u0026 npm install\",\n        \"install:sv\": \"cd sv \u0026\u0026 npm install\",\n\n        \"build\":      \"npm run build:ui \u0026\u0026 npm run build:sv\",\n        \"build:ui\":   \"cd ui \u0026\u0026 npm run build\",\n        \"build:sv\":   \"cd sv \u0026\u0026 npm run build\",\n\n        \"start\":      \"cd sv \u0026\u0026 npm start\",\n\n        \"clean\":      \"npm run clean:ui \u0026\u0026 npm run clean:sv\",\n        \"clean:ui\":   \"cd ui \u0026\u0026 npm run clean\",\n        \"clean:sv\":   \"cd sv \u0026\u0026 npm run clean\",\n\n        \"dev\":        \"stmux -w always -e ERROR -m beep,system -- [ [ \\\"npm run dev:ui\\\" .. \\\"npm run dev:sv\\\" ] : -s 1/3 -f \\\"npm start\\\" ]\",\n        \"dev:ui\":     \"cd ui \u0026\u0026 npm run build:watch\",\n        \"dev:sv\":     \"cd sv \u0026\u0026 npm run build:watch\"\n    }\n}\n```\n\nIn case of a build-time error in the frontend user interface (SV), the\nresult might be similar to the following one:\n\n![stmux example](etc/screenshot2.png)\n\nInstallation\n------------\n\n```\n$ npm install -g stmux\n```\n\n### Transitive Dependency\n\nThe dependencies of stmux transitively include\n[node-pty](https://github.com/Tyriar/node-pty) which must be\nbuilt with [node-gyp](https://github.com/nodejs/node-gyp)\nduring `npm install`. Please check out the documentation of\n[node-gyp](https://github.com/nodejs/node-gyp) on how to provide the\nnecessary C/C++ compiler environment on your operating system.\n\n* macOS: install the \"Command Line Tools\" under\n  \"Preferences \u0026gt; Downloads\" in Xcode.\n* Windows: open an elevated `cmd.exe` and run the commands\n  `npm install --global windows-build-tools` and\n  `npm config set msvs_version 2015 --global`\n* Windows Subsystem for Linux (WSL), Ubuntu distribution: run the commands\n  `sudo apt-get update` and\n  `sudo apt-get install -y python make build-essential`\n* Under Linux or FreeBSD you usually don't have to do anything.\n\nUsage\n-----\n\nThe following command line arguments are supported:\n\n```\n$ stmux [-h] [-V] [-w \u003ccondition\u003e] [-a \u003cactivator\u003e] [-t \u003ctitle\u003e]\n        [-c \u003ctype\u003e] [-n] [-e \u003cregexp\u003e] [-m \u003cmethod\u003e] [-M] [-f \u003cfile\u003e]\n        [-- \u003cspec\u003e]\n```\n\n- `-h`, `--help`\u003cbr/\u003e\n  Show usage help.\n- `-V`, `--version`\u003cbr/\u003e\n  Show program version information.\n- `-w \u003ccondition\u003e`, `--wait \u003ccondition\u003e`\u003cbr/\u003e\n  Wait after last finished command (and do not shutdown automatically),\n  either if any command terminated with an `error` or just `always`.\n- `-a \u003cactivator\u003e`, `--activator \u003cactivator\u003e`\u003cbr/\u003e\n  Use `CTRL+\u003cactivator\u003e` as the prefix to special commands.\n  The default activator character is `a`. For instance, for the\n  default activator case, opening the help popup requires you to\n  press `CTRL+a` (and release it again) and then (separately) press `?`.\n- `-t \u003ctitle\u003e`, `--title \u003ctitle\u003e`\u003cbr/\u003e\n  Set title on terminal. The default title is `stmux`.\n- `-c \u003ctype\u003e`, `--cursor \u003ctype\u003e`\u003cbr/\u003e\n  Set type of cursor  to `block` (default), `underline` or `line`.\n- `-n`, `--number`\u003cbr/\u003e\n  Show terminal number in terminal title.\n- `-e \u003cregexp\u003e[,...]`, `--error \u003cregexp\u003e[,...]`\u003cbr/\u003e\n  Observe terminal lines for errors (global option).\n  One or more regular expressions can be specified and have to match on a single line.\n  If a regular expression is preceeded with the prefix `!`, it is\n  required that it does not match.\n- `-m \u003cmethods\u003e`, `--method \u003cmethods\u003e`\u003cbr/\u003e\n  In case of detected errors, use the comma-separated\n  list of methods to perform user notification. The default\n  is no extra notification (just the terminal annotation).\n  Possible methods are `beep` and `system`.\n- `-M`, `--mouse`\u003cbr/\u003e\n  Enable mouse event handling. This enables the focus switching\n  by left mouse click, the scrolling with mouse wheel and\n  sends down mouse events to the terminal as mouse key sequences.\n- `-f \u003cfile\u003e`, `--file \u003cfile\u003e`\u003cbr/\u003e\n  Read specification `\u003cspec\u003e` from a configuration file. The\n  default is to use the specification inside the command line arguments\n  or (alternatively) to read the specification from `stdin`.\n\nThe following PEG-style grammar loosly describes the specification `\u003cspec\u003e`.\nFor exact details see the [real PEG grammar of stmux](src/stmux-2-parser.pegjs).\n\n```\nspec      ::= \"[\" directive (\":\"  directive)* \"]\"  /* vertical   split */\n            | \"[\" directive (\"..\" directive)* \"]\"  /* horizontal split */\n\ndirective ::= option* spec                         /* RECURSION */\n            | option* string                       /* shell command */\n\noption    ::= (\"-f\" | \"--focus\")                   /* focus terminal initially */\n            | (\"-r\" | \"--restart\")                 /* restart command automatically */\n            | (\"-d\" | \"--delay\") number            /* delay \u003cnumber\u003e seconds on restart */\n            | (\"-t\" | \"--title\") string            /* set title of terminal */\n            | (\"-s\" | \"--size\") size               /* request a size on terminal */\n            | (\"-e\" | \"--error\") regexp            /* observe terminal for errors (local option) */\n\nsize      ::= /^\\d+$/                              /* fixed character size */\n            | /^\\d+\\.\\d+$/                         /* total size factor */\n            | /^\\d+\\/\\d+$/                         /* total size fraction */\n            | /^\\d+%$/                             /* total size percentage */\n```\n\nThe following keystrokes are supported under run-time:\n\n- `CTRL`+*activator* *activator*:\u003cbr/\u003e\n  Send the `CTRL`+*activator* key-sequence to the focused terminal.\n- `CTRL`+*activator* `BACKSPACE`:\u003cbr/\u003e\n  Switch the focus to the previous terminal in sequence.\n- `CTRL`+*activator* `SPACE`:\u003cbr/\u003e\n  Switch the focus to the next terminal in sequence.\n- `CTRL`+*activator* `LEFT`/`RIGHT`/`UP`/`DOWN`:\u003cbr/\u003e\n  Switch the focus to the best matching terminal in a direction.\n- `CTRL`+*activator* `1`/`2`/.../`9`:\u003cbr/\u003e\n  Directly switch to a particular terminal.\n- `CTRL`+*activator* `n`:\u003cbr/\u003e\n  Toggle showing/hiding of terminal numbers.\n- `CTRL`+*activator* `z`:\u003cbr/\u003e\n  Toggle the zooming of focused terminal.\n- `CTRL`+*activator* `v`:\u003cbr/\u003e\n  Switch the focused terminal into visual/scrolling mode.\n  Use `PAGEUP`/`PAGEDOWN` during this mode to scroll up/down.\n  Any other key leaves this mode.\n- `CTRL`+*activator* `l`:\u003cbr/\u003e\n  Relayout the screen.\n- `CTRL`+*activator* `r`:\u003cbr/\u003e\n  Restart the program in the focused terminal.\n- `CTRL`+*activator* `k`:\u003cbr/\u003e\n  Kill the application and all shell commands in all terminals.\n- `CTRL`+*activator* `?`:\u003cbr/\u003e\n  Show help window.\n\nSpecification Examples\n----------------------\n\n- `stmux [ A ]`:\n\n    ```\n    +-----------+\n    |           |\n    |     A     |\n    |           |\n    +-----------+\n    ```\n\n- `stmux [ A .. B ]`:\n\n    ```\n    +-----+-----+\n    |     |     |\n    |  A  |  B  |\n    |     |     |\n    +-----+-----+\n    ```\n\n- `stmux [ A : B ]`:\n\n    ```\n    +-----------+\n    |     A     |\n    +-----------+\n    |     B     |\n    +-----------+\n    ```\n\n- `stmux [ [ A .. B ] : C ]`:\n\n    ```\n    +-----+-----+\n    |  A  |  B  |\n    +-----+-----+\n    |     C     |\n    +-----------+\n    ```\n\n- `stmux [ [ A : B ] .. C ]`:\n\n    ```\n    +-----+-----+\n    |  A  |     |\n    +-----+  C  |\n    |  B  |     |\n    +-----+-----+\n    ```\n\n- `stmux [ [ A : B ] .. [ C : D ] ]`:\n\n    ```\n    +-----+-----+\n    |  A  |  C  |\n    +-----+-----+\n    |  B  |  D  |\n    +-----+-----+\n    ```\n\n- `stmux [ [ A .. B ] : [ C .. D ] ]`:\n\n    ```\n    +-----+-----+\n    |  A  |  B  |\n    +-----+-----+\n    |  C  |  D  |\n    +-----+-----+\n    ```\n\n- `stmux -- [ [ -s 1/3 A .. B ] : [ C .. -s 1/3 D ] ]`:\n\n    ```\n    +---+-------+\n    | A |    B  |\n    +---+---+---+\n    |    C  | D |\n    +-------+---+\n    ```\n\nLicense\n-------\n\nCopyright (c) 2017-2024 Dr. Ralf S. Engelschall (http://engelschall.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fstmux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frse%2Fstmux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fstmux/lists"}