我需要做一个.command
文件脚本/批处理。启动它(双击)它必须是那些东西:
cd "dirname "$0""
)答案 0 :(得分:0)
鉴于您明确要创建终端窗口,请考虑使用 AppleScript 创建应用程序:
Script Editor
(最多10.9,AppleScript Editor
)Save As
对话框中的弹出列表)到所需的文件夹。# Determine the folder in which this app is located.
set thisFolder to do shell script "dirname " & quoted form of POSIX path of (path to me)
# Sample commands to execute in the new windows.
set cmds to {"date", "echo $$"}
tell application "Terminal"
# Create 2 new windows, change to the
# this app's folder, and execute the respective command.
repeat with i from 1 to 2
do script "cd " & quoted form of thisFolder & "; " & item i of cmds
end repeat
# Activate Terminal.app
activate
end tell
我建议在*.command
文件上使用应用程序的原因是,在创建所需文件之前,后者首先在终端窗口中打开本身窗口,这在视觉上具有破坏性(并且,根据您的Terminal.app偏好,可能会打开额外的窗口)。
或者,您可以将其转换为美德并使用*.command
文件自己的窗口作为第一个终端窗口,并且只创建一个附加窗口。