MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / openInTerminal

Method openInTerminal

src/main/utils/appleScriptHelper.ts:184–200  ·  view source on GitHub ↗

* 在终端中打开指定路径 * @param path 要打开的路径 * @returns 是否成功打开

(path: string)

Source from the content-addressed store, hash-verified

182 * @returns 是否成功打开
183 */
184 async openInTerminal(path: string): Promise<boolean> {
185 try {
186 // 转义路径中的单引号
187 const escapedPath = path.replace(/'/g, "'\\''")
188 const script = `
189 tell application "Terminal"
190 activate
191 do script "cd '${escapedPath}'"
192 end tell
193 `
194 await this.execute(script)
195 return true
196 } catch (error) {
197 console.error('[AppleScript] 在终端打开路径失败:', error)
198 return false
199 }
200 }
201
202 /**
203 * 显示系统通知

Callers 1

openTerminalMethod · 0.80

Calls 1

executeMethod · 0.95

Tested by

no test coverage detected