MacOS – How to run Unison through automator

automatormacosterminal

I like to set up unison through Automator to run in the background to sync up two of my folders in a dropbox-like manner, but Automator apparently fails to run unison through shell script. I have tried both the regular terminal command:

unison /folder1 /folder2

and the full path for unison:

/usr/local/Cellar/unison/2.40.102/bin/unison /folder1 /folder2

Best Answer

You will want to run it through Apple Script and iTerm.

tell application "iTerm"
    make new terminal
    tell the current terminal
        activate current session

        launch session "Default Session"
        tell the last session
            write text "unison /folder1 /folder2"
        end tell
        terminate the last session

    end tell
end tell

Remember to double forward slash for space in the path in your folder roots.

I am not sure how to run it in the background. This script will bring the iTerm to focus.