shell2node
v0.10.2
Published
Record a shell pipeline and generate a reusable Node.js script that reproduces the pipeline with streaming child processes. Turn throwaway terminal magic into shareable, maintainable scripts.
Downloads
4
Maintainers
Readme
Installation
npm install -g shell2nodeFeatures
- 🎥 Interactive Capture Mode - Records commands from your existing bash/zsh shell sessions
- 🔄 Streaming Reproduction - Generated scripts maintain original command streaming behavior
- ⚡ Shell Semantic Preservation - Uses
sh -cto preserve shell features like pipes, redirections, and expansions - 📁 Automatic Organization - Saves generated scripts with timestamps and metadata
- 🛡️ Safe Execution - Includes proper error handling and exit code propagation
Quick Start
- Start capture mode:
shell2node capture- Run your commands as normal:
# These will be recorded
find . -name "*.ts" -type f
cat file.txt | grep "pattern" | wc -l
curl -s https://api.example.com/data | jq '.items[]'- Save and generate script:
shell2node save- Run generated script:
node generated/2024-01-15T10-30-00Z-replay.jsExample
Captured commands:
$ find src -name "*.ts" | xargs wc -l
$ cat data.json | jq '.metrics[]' | sort -nGenerated Node.js script:
// Generated by shell2node (MLP)
// Captured commands: 2
// Generated at: 2024-01-15T10:30:00.000Z
import { spawnSync } from 'child_process';
function run(cmd) {
console.log('> ' + cmd);
const r = spawnSync('sh', ['-c', cmd], { stdio: 'inherit' });
if (r.error) {
console.error('Failed to run command:', r.error);
process.exit(r.status || 1);
}
if (r.status && r.status !== 0) {
console.error('Command exited with code', r.status);
process.exit(r.status);
}
}
(async () => {
run(`find src -name "*.ts" | xargs wc -l`);
run(`cat data.json | jq '.metrics[]' | sort -n`);
})();Who Is This For?
- DevOps Engineers - Convert deployment scripts into maintainable Node.js code
- Data Scientists - Reproduce complex data processing pipelines
- System Administrators - Document and version control administrative tasks
- Developers - Share complex build processes with team members
- Technical Writers - Create reproducible examples for documentation
Supported Shells
- ✅ Bash (primary support)
- ✅ Zsh (full support)
- ⚠️ Other shells (basic support, may not capture all commands)
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT — see LICENSE for details.
Support
For support and questions, please open an issue on GitHub or contact [email protected]
