Install Termux and Termux Widget
From Github Termux ,[^1] Github Termux Widget [^2] download the APKs and install them. You can use F-Droid as well.
Give Termux access to your storage using the following command :[^3]
Setup Git and Github for Manipulating Repositories
Use the following commands to setup git and github via HTTPS :
You can use SSH as well
Login to your Github account :
Update the git configs :
Now you should clone your repository, try to use the following commands :
If you are on Android 12, you’ll get an error with the command required to add the repository to a security list or something like that. Do it, and these commands should work.
Setup the Sync Script Shortcut
Create a directory for the shortcuts :[^4]
Create the sync script :
Add the following script :[^5]
Create the widget and add it to your home screen. That’s it, you just need to launch it to sync your Obsidian vault. It means you need to launch it before and after editing notes. If you putted your script inside ~/.shortcuts it will launch in the foreground, and if it was inside ~/.shortcuts/tasks then it will launch in the background. I recommend using as a widget the one that execute the code in the foreground and keep the other one for the Cron job.
Setting up an Automatic Execution of the Script
If you want to automatically sync your vault every hour, for instance, you can do it using a Cron job. [^6] [^7] [^8]
First, you need to install Cron :
Then, you’ll restart Termux then run the following :
Finally, you’ll end up with the crontab -e
command in the nano text editor. Add the following :
You can find information about Cron job easily on the internet.[^9]