UpAndAdam's idea was indeed a good idea. However, git stash
is not exactly used for these "workflows," as the temporary "overlays" cannot be discarded. There is no command to do that. I have no intention of making branches off of stashed files, nor do I want manually pick out what should be committed+pushed to the remote.
What I did was run two checkout
commands with very easy regular expressions (in NewTerm2, as A-Shell didn't budge with Libgit2):
git checkout -- [A-Z]/.obsidian/appearance.json
git checkout -- [A-Z]/.obsidian/plugins/obsidian-style-settings/data.json
This took care of my "temporary" 52 files, which are now withdrawn from the workspace and I am ready to commit and push my changes.
This whole thing (solution?) is very clunky indeed as it is, especially because I need a one-button solution.
Hereby, I present that solution.
Requirements
Patience. No. There is no patience needed. It'll all be a cinch.
- 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 open sshd_config
in the text editor of Filza.
Where you see the line # Port 22
, type underneath Port 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.
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.
Obsidian Forum
On the Obsidian Forum, I talk a bit more about the setup:
https://forum.obsidian.md/t/ios-macos-siri-shortcut-jb-git-apply-and-switch-between-the-same-multiple-settings-for-all-vaults/59276