文章摘要
作者介绍了自己改进的工作流模式make.ts,通过将命令写入文件再执行,替代手动输入重复命令的方式,尤其适用于多进程应用场景。这种方法比依赖shell历史记录更高效,能更好地保存和复现实验过程。
文章总结
《make.ts:一种高效的交互式脚本工作模式》
作者matklad在2026年1月27日分享了一种改进的脚本工作模式,通过将临时命令持久化到文件中来提升效率。
核心模式: 1. 使用git忽略的固定文件名(如make.ts)记录交互式命令 2. 通过执行脚本文件替代手动输入命令 3. 保留命令历史的同时避免复杂的shell操作
优势: - 使用专业编辑器处理复杂命令 - 支持多命令组合执行 - 促进命令的幂等性改进 - 便于转化为正式脚本 - 简化多进程管理
技术细节: 1. 采用Deno运行时环境(支持TypeScript) 2. 推荐dax库处理子进程 3. 利用async/await管理并发 4. 示例展示了TigerBeetle集群测试场景的完整演进过程
典型演进路径: 从简单的命令组合 → 添加错误处理 → 引入并发控制 → 最终形成参数化基准测试框架
核心理念: 将临时命令及时固化为脚本文件,比依赖shell历史记录更有利于工作流的持续优化。这种方法特别适合需要反复调试的复杂操作场景。
评论总结
以下是评论内容的总结,平衡呈现不同观点并保留关键引用:
支持使用TypeScript/Deno替代Shell脚本
- 认为Deno/Zx比Shell和Python更适合脚本编写,解决了Python的模块路径等问题
- 关键引用:
- "100x better than shell scripting and like 5x better than Python scripting" (评论2)
- "Shell makes for a terrible scripting language...around the time I have to introduce the first
if" (评论5)
推荐其他工具替代方案
- 提到npm scripts、Make、Just、mise tasks等现有方案
- 关键引用:
- "most people use npm scripts in package.json" (评论6)
- ""Just" is exactly made for this...similar to a makefile but without the painpoints" (评论13)
对具体实现的讨论
- 关注文件哈希跟踪、路径空格处理等技术细节
- 关键引用:
- "Does it track file hashes or just timestamps?" (评论3)
- "how to ls a directory with spaces in name" (评论15)
工作流程建议
- 提倡保存和版本控制脚本,反对临时性使用
- 关键引用:
- "Why not version control it, share it with colleagues" (评论16)
- "~/make.ts is better...same wherever you are" (评论14)
终端工具推荐
- 多个用户推荐fzf等工具改进终端体验
- 关键引用:
- "integrate fzf into your shell...fuzzy shell history search" (评论17)
- "greatly improved my terminal ux" (评论8)
写作风格赞赏
- 特别称赞文章的手写风格和非LLM生成特点
- 关键引用:
- "breath of fresh air...clearly hand-written" (评论7)