Execute shell commands via Obsidian URI #195
Taitava
started this conversation in
Ideas - done & released
Replies: 2 comments 1 reply
-
Will be done in version
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta test |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I started this discussion based on this discussion: #193.
Quote from @hakonhagland in #193 (reply in thread):
Yes, this can be used. 👍
Quote from @hakonhagland in #193 (comment):
Yea, that's a good example. Small changes to the url:
obsidian://shell-commands?id=XYZ&_param1=77&_another=whatever
(Edit 2022-04-15: Actually, keywordid=
will be changed toexecute=
).Here,
_param1
and_another
would be custom variable names, and they could be accessed in a shell command like this:echo "My custom variable values are: "{{_param1}}" and "{{_another}}
. The names are freelydecideable, but they need to start with an underscore_
. Documentation about custom variables comes when the first version of SC that supports them (0.12.0
) will be published.Aliases are not used as identifiers. They are not unique (you can make two shell commands that use the same alias, there's no restriction for that). So you need to use ids in the url.
And just to reflect my above mention about the custom variables, your shell command would look like this:
okular -p {{_param1}} /home/hakon/pdf_reference.pdf
I need to think about it, can't promise anything yet. I could come up with a plan to create some kind of variable for retrieveing a clicked link's label text. My first solution would not be a JavaScript parser for this, I'd pass the link text to the shell command as a whole, and then write the parser in the shell command itself or make it a script file or something.
What comes to being able to execute custom JavaScript via SC in general, it's worth planning and something I want to have at some point, but won't happen soon. I think it will require a public API from this plugin and I'm not ready for that yet. But once I feel comfortable planning it more, I'll write some topic(s) for supporting custom JavaScript.
I'm not sure if the caret position goes to the link when clicking. I think a more robust solution would be to hook into the link clicking event.
Current situation
At the moment, Obsidian Advanced URI plugin can be used to execute commands created in SC, using a URL like this:
obsidian://advanced-uri?vault=name&commandid=obsidian-shellcommands%253Ashell-command-99
This, however, does not support passing custom values to the shell command, which can be crucial in some use cases.
Beta Was this translation helpful? Give feedback.
All reactions