0

我有一些 shell (Bash) 脚本可以处理目录中的一些视频文件。而不是每次启动(打开)终端窗口,然后输入脚本名称,我宁愿在 Finder 的资源管理器工具栏中安装一个图标,以便只需单击它即可完成工作(就像OpenTerminal一样,如果你知道那个工具)。我想象的结果是这个:

  • 点击图标

  • 出现一个终端窗口,它会自动执行一种

    cd /the/path/where/I/was/in/the/finder/window; run_my_script.sh
    

知道该怎么做吗?(这是可行的,因为 OpenTerminal 做到了)

4

2 回答 2

0

在 AppleScript 编辑器中将这样的内容保存为应用程序:

activate application "SystemUIServer" -- http://www.openradar.me/9406282
tell application "Finder"
    activate
    set p to POSIX path of (insertion location as text)
end tell
tell application "Terminal"
    activate
    do script
    repeat while contents of window 1 starts with linefeed
        delay 0.01 -- wait to get a prompt
    end repeat
    do script "cd " & quoted form of p in window 1
    do script "uptime" in window 1
end tell
于 2013-01-21T15:52:27.427 回答
0

添加到脚本顶部,

  #!/bin/bash
  cd /the/path/where/I/was/in/the/finder/window  
  ....
  ....

之后在终端上运行以下命令

ln -s run_my_script.sh /bin/run_my_script.sh

于 2013-01-21T15:17:25.570 回答