In the last two months or so, I was trying to figure out how to optimize my work on the iPad. I have a large vault, so I needed to cut it up.
Then with all those temporary vaults, came other issues. First, when I installed and enabled a new plugin for A, I had to do the same for B-Z (which entailed copying the folder into the plugin folders of B-Z and appending each community-plugins.json file in B-Z).
I had to find a way to automate this.
Then, on the heels of that, I thought what do I need to switch between two sets of settings (e.g. day and night) and apply all changes to A-Z subvaults?
First, I was thinking URL schemes, or thought maybe the Obsidian Advanced URI plugin could help, but not every single case.
So I thought I could try and do it with git, and I finally managed to make it work.
My solution involves using two buttons (Shortcuts; I always keep the on the right in Slide-Over, as if it was an Edge Panel a la Android) that effect changes using git stash
and git checkout
.
Requirements
- A jailbroken device. JB’ing is pretty straightforward these days, e.g. with the Palera1n ISO (look it up).
- Filza JB file manager.
- Some expertise or proclivity to learn something about automation, namely iOS Shortcuts.
- NewTerm2 terminal: optional.
- As this deals with a git repo from the onset, ostensibly you’d need git. If you are using Obsidian sync, you need to figure out a different way with A-Shell, dealing with search and replace in files.
Setup
I’m assuming you’ve jailbroken your device and installed Filza already.
In order to provide a one-button solution, what we need to do is SSH into our own device’s Localhost.
- In Filza, go into
/etc/ssh
and opensshd_config
in the text editor of Filza.
Where you see the line# Port 22
, type underneathPort 2222
without the hash (the hash stands for comment, now it will be a setting). Save and exit the file. - You can also un-hash the line with port 22, but we’ll be using port 2222 later.
We can head over to our Shortcuts app. I am assuming you already have some shortcuts to do with Obsidian.
Here I’ll just show you how to call these shortcuts silently in SSH.
I am only showing the “difficult” part here, so this can be incorporated into your shortcut e.g. one that runs pull from your remote first, etc.
- Create a new shortcut:
Search for and rag in “Run script over SSH”. For Host, type in 127.0.0.1
, port will be 2222
, user will be root
, and for authentification, we use the Password method, where the default root password is alpine
(type it in). Input is left empty.
In the script area, you need to change into a directory (cd
) where your repo resides. You can use symbolic links in Filza beforehand. I am using the directory I was accessing git from in NewTerm2. I am using A to Z folders and was making changes to these files in those folders, so I am revoking the changes by checking them out, that is rolling back to what I had before I applied the stash, as per the instructions by Adam.
In my case, the following will cause light mode and different theme settings to be active in all of my subvaults, until (using another Shortcut) I re-apply the stash again to apply the dark mode.
Write in your code in your script area:
cd /var/mobile/<RepoName>
git checkout -- \[A-Z\]/.obsidian/appearance.json
git checkout -- \[A-Z\]/.obsidian/plugins/obsidian-style-settings/data.json
The first time I was running it, I received the error:
fatal: detected dubious ownership in repository at...
I followed the on-screen suggestion but nothing happened. I manually edited my config file, I even used the wildcard asterisk; nothing. Same error. Then it occurred to me to run the command from inside the Shortcut, in this very same SSH command, but instead of global
I was using system
:
cd /var/mobile/<RepoName>
git config --system --add safe.directory /private/var/mobile/Containers/Data/Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/Documents/<RepoName>
- Note: because the UUID of your Obsidian container/folder changes on each update of the app, it is worthwhile to have and run a shortcut that puts the new UUID into a global variable (of the ToolBox Pro app), and you can use that in all other shortcuts (better than updating your Obsidian PATH in a dozen shortcuts).
Then it was working properly.
The above only caters to a simple use case, yet. You can use multiple stashes and multiple lines in the SSH part of the shortcut, so you can apply various changes unto different vaults with the push of a button.