😰 Trying to automate git backup using shell (stdin for custom shell in WSL) #371
Replies: 4 comments 6 replies
-
@Taitava suggested 👇🏻 (Transposed from #89 ) Hi! Thank you for your message! 🙂 Yeah, I think it might be better to repost this in a new discussion. This discussion #89 is a bit long already 🙂. I do agree that having a possibility to open up an interactive CLI window would help a lot here, so you could put that in the new discussion's name 👍 . Meanwhile, you could also try to: Invoke WSL using a custom shell. This way you don't need to include the wsl -d Ubuntu-22.04 --cd "/mnt/e/00 MD Vault/Obsidian/" --exec part in your actual shell command. Just git add . && git commit -m "backup at "{{date:HH:mm}} && git push origin main is enough. |
Beta Was this translation helpful? Give feedback.
-
So... Indeed there was something I missed, the custom shells. Let's give that a try. Anyway, following the guide... this is important, Next, setup of the command. Let's go. I've tried First let's try to use directly outside obsidian, Now let's try that with sheel commands in obsidian. I change the command to something like this So wait... why is that? Oh boy, I forgot to change the enviroment of the command, Another try and... |
Beta Was this translation helpful? Give feedback.
-
Now to use the stdin to remove sshpass |
Beta Was this translation helpful? Give feedback.
-
Sorry it took me this long to get back to you! I'll try to cover all the questions you posted in this single message. Please let me know, if I missed someting.
Thank you a lot for your kind words! 🙂
Good point, I think I will add an explicit mention to the WSL guide that no
Nice feedback again 🙂. I'll write a detailed description of the regex. It's good to explain how the translator code works to clear things up.
Nice that it works at least with
Thank you for this tip! I'll add it to the documentation.
An excellent idea! 😎 It never crossed my mind. I'll definitely add a password field. I put it on a todo list here. I have some other field types in the works, too, and this one is so simple that I can include it at the same time I release other field types.
Sorry, can you tell me more about what you mean by this visualizer?
I'll take promoting these to actual settings in the UI into consideration. The hard part is to decide which tab they should belong to. I mean, they are related to shell commands, so they could be placed at the bottom of that tab. But the tab gets already easily crowded at least if a user has a lot of shell commands defined. And I'm trying to avoid adding a new tab, as the visual space is limited. :)
What do you mean by this? I think the current default behavior is that shell command fields get as tall as there are lines in the shell command. It has one issue though: it doesn't count soft-wraps, and might therefore be too short.
Yeah, that's currently the biggest missing piece in this otherwise near complete puzzle. My dream is to make all configurable elements/settings exportable/importable, so that a shell command that relies on e.g. specific prompts, custom variables, and a custom shell, could include all its "dependencies" in a single block of text.
Yes, if I recall correctly,
Sorry, I'm not an expert too, and don't know much about TTY raw mode. Actually, I'm not too familiar with
Sorry, I'm not familiar with Git's credential helpers / libsecret, either.
Probably you could have a shell command like
Sorry, I did not get the question. :)
Yeah, learning by reverse engineering. :) One thing that the documentation of this plugin lacks is a technical overview of the shell command execution flow. It has gotten quite complex over time.
Ok, there are some bugs in this plugin that settings views don't always get updated after changes. yea, if you can, please post an issue about it.
You can use Hot-Reload plugin for Obsidian to reload the plugin every time you build the main.js file. I'm using it and it works fantastically well.
If you have the realtime setting on,
Thanks! :)
Probably Git outputted stuff in one block, or so fast that this plugin was not fast enough to read the output before all of it became available. The realtime feature usually gets output content piece by piece when there is noticeable pauses in the output. I guess you executed just
Sorry, I'm not following. What does not work? Is there any output?
I have to say that I appreciate that you have taken the time to go through the source code of this plugin, trying to learn how it works! Not an easy task, I admit. 😎 |
Beta Was this translation helpful? Give feedback.
-
Copied from #89 👇🏻
Hi! I'm quite new to the plugin and most likely I'm streching the capabilities of
it. The thing, just for giving context, is that I want remove the git plugin and use shell commands instead. I use WSL and I like to use SSH for the repos within.
I'm wondering, if it would be possible to propmt in the moment when the passphrase is needed.
I thought first to use a prompt to get the password and pass it, which could be theoretically possible using something like sshpass, but I think it would be cooler to don't have such a potentially insecure tool installed as quoting from an article
I know what I'm doing is not very secure as well, at least could be, but anyways, this is how I learn things and maybe there is something in Shell-Commands I don't know yet.
The command I try to make work is this one
wsl -d Ubuntu-22.04 --cd "/mnt/e/00 MD Vault/Obsidian/" --exec git add . && git commit -m "backup at {{date:"HH:mm"}}" && git push origin main
It launches wsl in the cli by default, in this case cmd, navigates to the path and executes the git commands.
From
I guess stdin might be the solution, but following the thread might not be possible? I tried
echo "{{_pass}}" | git push origin main
and didn't work either. Might be related to the TTY access mentioned before.So..., stdout handling wouldn't work either...
I don't know, maybe this kind off topic, I was about to open a discussion instead but this might be nearer to the real subject. Let me know if I should repost it there.
In any case, the ideal situation would be that the cli is showing and I can type the passphrase there.
but also it would be really cool to use the prompt. What do you think?
Beta Was this translation helpful? Give feedback.
All reactions