当前位置: 首页 > news >正文

多项目终端环境初始化开发环境方案

多项目终端环境初始化开发环境方案

‌背景需求‌

在高峰期同时维护4个开发项目时,频繁切换环境存在以下痛点:

  1. 需手动进入不同目录,再启动前后端服务
  2. 多项目开发快速切换
  3. 主力开发机是MacBook/Mac Mini,需要优先支持macos

‌解决方案‌

通过AppleScript实现iTerm自动化环境切换,以个人的一个yutop项目为例:

tell application "iTerm"activate# Create new tabtell current windowcreate tab with default profileend tell# Split panetell current session of current windowsplit vertically with default profileend telltell first session of current tab of current windowsplit horizontally with default profileend tell# -- 后端服务tell first session of current tab of current windowwrite text "cd /opt/dir/yumore/yutop/top-go/"write text "go run main.go"end tell# -- 前端开发tell second session of current tab of current windowwrite text "cd /opt/dir/yumore/yutop/top-vue"write text "pnpm run dev"end tell# -- 版本控制lazygittell third session of current tab of current windowwrite text "cd /opt/dir/yumore/yutop/"write text "lazygit"end tell
end tell

以上内容写入文件yutop.scpt

执行方式‌

osascript yutop.scpt  # 需提前在系统设置中授予iTerm自动化权限

‌后续扩展

  1. 封装为launch_project.sh批量管理运行多个.scpt文件
  2. 添加包装kill -9命令批量结束项目进程

当前方案已在实际开发中验证,切换效率提升90%
在这里插入图片描述

http://www.dtcms.com/a/300219.html

相关文章:

  • 【RHCSA 问答题】第 10 章 配置和保护 SSH
  • cacti漏洞CVE-2022-46169的复现
  • 界面规范2-列表上
  • NTLite Ent Version
  • 文件IO——bmp图像处理
  • GRE、MGRE实验
  • 机器学习(重学版)基础篇(概念与评估)
  • 算子推理是什么
  • GStreamer中Pipeline(管道)
  • 速通python加密之base64
  • 《C++》模板详解
  • odoo代码分析(二)
  • 一键实现推送服务:Docker部署ntfy开源通知系统指南
  • STM32-定时器的基本定时/计数功能实现配置教程(寄存器版)
  • 数据结构习题--删除排序数组中的重复项
  • Linux内核设计与实现 - 第13章 虚拟文件系统(VFS)
  • TCP如何解决网络切换问题
  • Flutter开发实战之原生平台集成
  • FROM stakater/java8-alpine 构建cocker镜像
  • React入门学习——指北指南(第三节)
  • 【星野AI】minimax非活动时间充值优惠漏洞
  • 数据存储:OLAP vs OLTP
  • java基础(day16)set-map
  • 从0到1学Pandas(七):Pandas 在机器学习中的应用
  • AI Agent开发学习系列 - langchain之LCEL(5):如何创建一个Agent?
  • React入门学习——指北指南(第五节)
  • java集合框架面试点(2)
  • [2025CVPR-图象合成、生成方向]ODA-GAN:由弱监督学习辅助的正交解耦比对GAN 虚拟免疫组织化学染色
  • 《每日AI-人工智能-编程日报》--2025年7月26日
  • 四大主流AI Agent框架选型梳理