This repo includes scripts that are used in Termux on my Android devices. Termux is an Android terminal emulator and Linux environment app.
The main purpose is to sync my Obsidian vault between devices via Git.
The idea to use Termux for automatic syncing came from Rene Schallner: Syncing your Obsidian vault to Android via an encrypted GitHub repository
For syncing I'm now using the script git-sync.sh
by Simon Thum: simonthum/git-sync
- Install required packages:
pkg install git openssh rsync
- Setup storage: Termux-setup-storage
SSH access to Termux from your computer (optional, but makes it much easier): Remote Access
If you want to use SSH for accessing your remote Git repositories, create a new key pair:
ssh-keygen -t ed25519 -C "your optional comment"
eval "$(ssh-agent -s)" # start the ssh-agent in the background
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
Copy the public key to your Git remove server (GitHub, ...).
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
Clone this repo inside Termux:
cd ~
git clone https://github.com/davidkopp/termux-scripts.git
Clone repos via SSH (e.g. your Obsidian vault):
cd ~/storage/shared
git clone [email protected]:YOUR_NAME/YOUR_REPO.git
The end result for me looks like that (you can choose other paths if you want):
- termux-scripts:
~/termux-scripts
- Obsidian vault:
~/storage/shared/notes
Note: The script setup-git-repo.sh
makes some configurations. If you want other options, modify it before executing it.
- Copy
repo.conf
fromtermux-scripts
to the home directory inside Termux and edit it to your personal needs:cp repo.conf $HOME/repo.conf nano $HOME/repo.conf
- Make the setup scripts executable:
chmod +x setup-scripts.sh chmod +x setup-git-repo.sh
- Run setup scripts
./setup-scripts.sh ./setup-git-repo.sh
Note: Creating symlinks in the .shortcuts
directory that link to scripts outside of the directory are not allowed anymore (see here).
After exiting Termux, you can open your launcher’s widget menu, select Termux:Widget and place it on your home screen. To automatically commit and sync changes I use the Termux add-on Termux:Tasker. As an alternative you can also setup a cronjob (see here for advice).
curl https://raw.githubusercontent.com/simonthum/git-sync/master/git-sync -o git-sync.sh