MacOS – Add shortcut for multiple terminal commands

findermacosterminal

I find myself doing this too often – navigate to a folder, "Open Terminal Here", then "mate .", then "python -m SimpleHTTPServer"

I was wondering if it's possible to add a button to the finder toolbar that when I click it runs those two commands for me for the folder that I'm currently in?

Thanks

Best Answer

The following AppleScript should work, which you can save as an application and put in your Finder toolbar.

tell application "Finder"
    try
        set folderPath to (quoted form of POSIX path of (target of front window as alias))
        tell application "Terminal"
            do script "cd " & folderPath & "; mate .; python -m SimpleHTTPServer"
        end tell
    end try
end tell