DEV Community

Hiromi
Hiromi

Posted on

Obsidian integration with Android

With a Linux computer and an Android, when I decided to integrate Obsidian into my daily use, it became quite tricky.

In order to integrate Obsidian on my phone, I should either pay the app fee (something around 4/5 dollars monthly) or integrate it with a cloud system. The first alternative could be perfect if I were already sure how I would use the app for better note-taking, but it was still a trial period, in which I needed to test it. On the other hand, the second would be perfect if I were not already dealing with low storage in my cloud accounts. Therefore, I needed to look for a third alternative.

Before, I had been working with Obsidian for the past three years only on my computer, integrated with Git. This Git was connected from my Obsidian local folder to a repository, and I created a pipe to run once I closed Obsidian for that specific repository. Therefore, I decided to do the same on my phone.

This video mentioned the approach mentioned above, but I was not able finding the same app in Android. The alternative as Termux.

"_Termux is an Android terminal emulator and Linux environment app that works directly with no rooting or setup required. _" With this app, it is possible to navigate around folders and files behind the scenes on Android, just like we use a computer.

After the installing Termux, just treat the phone like your computer.

1) Download Termux.

2) Install Git in Termux, this blog has a great explanation. Below has the code, adapted:

pkg upgrade
pkg install git -y
Enter fullscreen mode Exit fullscreen mode
  • With git installed, create a directory inside of storage (main Android folder, after it is easier to find).
  • Clone your obsidian folder notes from Git to your phone.
  • I recommend to try a commit, in order to configure the credentials. It's useful getting the token, user and email configured as --global.

3) Download Obsidian, then choose to open a local folder as a vault. From there, navigate through the folders to find the one cloned in the step before, and it is done. You have the same setup you had locally, now on your phone.

Recommendation: For me, navigate in Termux is a bit time-consuming because I don't master the virtual keyboard as well as a physical one. I strongly recommend creating an executable file in the initial location from Termux that update the Obsidian repo locally, then commits and pushes. Whenever you finish your notes, you can open Termux and just run a executable quiclky, avoiding Git conflicts and guarantee computer-phone integration.

Here is an executable example, with some improvements from Claude:

cd {place the local of the repo} || exit 1  # adjust to your actual path

--Pull any changes made on other devices first
git pull origin main

--Only commit if there's something to commit
if [ -n "$(git status --porcelain)" ]; then
  git add -A
  git commit -m "Sync from $(date '+%Y-%m-%d %H:%M:%S')"
  git push origin main
else
  echo "Nothing to commit."
fi
Enter fullscreen mode Exit fullscreen mode

Refs:
https://www.youtube.com/watch?v=PScdHzUiBLA
https://termux.dev/en/
https://oraculix.com/2023/06/23/synchronizing-obsidian-md-with-android-using-git/

Top comments (0)