I couldn't install OCaml in Termux, so there is workaround which uses x86-64 binaries and QEMU:
pkg install qemu-user-x86-64
curl -LO https://github.com/bcpierce00/unison/releases/download/v2.53.7/unison-2.53.7-ubuntu-x86_64-static.tar.gz
mkdir unison-unpacked
tar xvzf unison-2.53.7-ubuntu-x86_64-static.tar.gz -C unison-unpacked
cp unison-unpacked/bin/unison unison
cp unison-unpacked/bin/unison-fsmonitor unison-fsmonitor-bin
cat << EOF > unison-fsmonitor
#!/data/data/com.termux/files/usr/bin/bash
qemu-x86_64 /data/data/com.termux/files/home/unison-fsmonitor-bin
EOF
chmod +x unison-fsmonitor
To start continuous synchronization, run:
qemu-x86_64 unison -repeat watch -ignorelocks -fat -times "your_profile_name"
IDK if it's possible to create profile using Unison CLI, I just copied existing profile from PC and edited it like so:
# Unison preferences
root = /storage/emulated/0/Documents/my_synced_data
root = ssh://unison@serverhostname//home/unison/Sync/my_synced_data
sshargs = -C
If you don't want to enter ssh key password every time, you can create passwordless ssh key and use it on your serverhostname
. Do not forget to update ~/.ssh/config
in Termux!
# place passwordless key first!
IdentityFile ~/.ssh/unison
# other keys (if you have any)
To start multiple profiles simultaneously:
bash -c "qemu-x86_64 unison -repeat watch -ignorelocks -fat -times 'profile1' & qemu-x86_64 unison -repeat watch -ignorelocks -fat -times 'profile2'"
You also can add following alias to ~/.profile
to launch synchronization faster:
alias uuu="bash -c \"qemu-x86_64 unison -repeat watch -ignorelocks -fat -times 'profile1' & qemu-x86_64 unison -repeat watch -ignorelocks -fat -times 'profile'\""
Check out Termux:Widget if you want to create desktop shortcut!