I use an online git repository to backup my local notes and writing stuff.
With Termux and Termux Widget, we can git push
to back up them effortlessly.
Requirements
- Termux
- Termux Widget
- Having
git
installed - Using SSH key for your git repository
Steps
- Add a Termux Widget to your device’s home screen
- Add script files to
~/.shortcuts/
Here is an example script file that does back up or git push
my note directory. It is located in /storage/emulated/0/myWriting
File: ~/.shortcuts/note_update.sh
echo 'Processing myWriting folder'
echo '================================='
echo ''
cd /storage/emulated/0/myWriting/
# This is call var assignment in bash
# varAssignment=$(git status --porcelain)
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "note back up"
git push
else
echo 'Nothing to commit'
fi
echo 'Done all'
- Just click on the script files shown on Termux Widget to run them.