Pergunta

I have some shell (Bash) scripts that process some video files in a directory. Instead of everytime launching a (Open)Terminal window, then typing the script name, I'd prefer to install an icon in the Finder's explorer toolbar so that a simple click on it does the job (like OpenTerminal does, if you know that tool). The result I imagine is this one :

  • click on the icon

  • a terminal window appears which automatically does a kind of

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

Any idea how to do that ? (it's feasible since OpenTerminal does it)

Foi útil?

Solução

Save something like this as an application in AppleScript Editor:

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

Outras dicas

Add to top of the script,

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

After that run following command on the terminal

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top