Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
348 stars 11 forks source link

Wrap shell command output #262

Closed Taitava closed 1 year ago

Taitava commented 2 years ago

Quote from me in: https://github.com/Taitava/obsidian-shellcommands/discussions/244#discussioncomment-3211841

I think this is what you meant. Make it possible to configure text snippets that could be used as wrappers for output. E.g. the following could be an output wrapper text:

{{output}}

If the executed shell command is e.g. ls (lists files and directories), then an example resulting output could be:

MyFolder MyNote.md MyOtherNote.md

The wrapper texts could be defined in settings, and multiple shell commands could use the same wrapper if wanted - no need to redefine the same wrapper for every shell command. The wrapper could be used regardless of what output channel is used: when outputting into file, into clipboard or into a notification balloon or whatever.

TODO

Taitava commented 2 years ago

It's implemented now, but I still want to consider doing the variable parsing in output wrappers a bit differently. Currently, variables in output wrapper texts are parsed after executing a shell command. This has the following points:

I want to try to come up with an alternative solution that could parse variables in output wrappers before executing a shell command. That would solve the abovementioned three problems. It might be hard to do, though. That being said, even this current implementation is ok, if an improvement is too hard to make.

I won't release this feature until I've inpsected the alternative solution.

Taitava commented 2 years ago

I was able to implement the alternative solution.

Taitava commented 2 years ago

Only tests need to be made, then it's ready.

Taitava commented 1 year ago

Tests are done.


I just noticed that any variables used in output wrappers are escaped (except {{output}}), although they should not be. Output wrapper texts are not passed to shells, so escaping special characters in them should not be done, as the ecaping won't disappear in the end.

Taitava commented 1 year ago

Released now.