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
351 stars 11 forks source link

[Question] A Question About {{Variables}} #14

Closed FelipeRearden closed 3 years ago

FelipeRearden commented 3 years ago

Hello again @Taitava !!!

I'd like to ask you about Variables:

I'm thinking about a workflow that could need new variables as {{workspace}} and {{file_name}} without the .mdin the end

Have a great day !!!!

Taitava commented 3 years ago

Hi again @FelipeRearden ! 🙂

Variables in this plugin are made by me, so yes, I can add new variables or change the behavior of current ones. So feature requests about variables can be made! 🙂

Todo:

FelipeRearden commented 3 years ago

This is amazing @Taitava !!!

I'm so excited about this plug-in. We can do everything :)

Workspaces are a big deal in my Obsidian workflow. As you start to use, you gonna see that its a great idea but needs a lot of improve yet.


Now that I know that is feasible, let me deep dive to see if we can bring some new {{variables}} to our friends.

My idea is to use Shell Commands to input predefined text into other plug-ins to automate plug-ins that needs users decision.


We talk soon. Thanks again and have a great day!

Taitava commented 3 years ago

Now that I know that is feasible, let me deep dive to see if we can bring some new {{variables}} to our friends.

Great! 🙂 Just one tip: I think best ideas come from using the software (like you have done) and then over the time you just notice things that could be better. That's when the most useful ideas arise, and so far this is what your ideas have been: command aliases, the {{workspace}} variable, and to make the alias field to have focus. All of these came from a real need.

I just notice myself sometimes creating ideas and new features just because it's fun to create them, but it has a downside too: sometimes I develop a feature that is not actually never used or needed. These are ideas that did not arise while I was actually using the sofware in a real, practical situation, but that came to my mind when developing the software, which is a situation where I might be blind to what an actual user might need. For example, my feature idea #13 is something that came to my mind as "hey we could have this", but now that time has passed, I've come to think about maybe we will not need it. (Maybe the same holds true for #12 too).

TL;DR: Good ideas develop over a long period of time. Be careful what you wish for - you might get it. 🙂

My idea is to use Shell Commands to input predefined text into other plug-ins to automate plug-ins that needs users decision.

Can you elaborate more on this? I didn't quite get what you mean by "to automate plug-ins that needs users decision". 🙂

I have been thinking about a variable like {{input}}. When a command is executed, if the variable is present in the command, the plugin could open an small popup window and ask the user to type something, that will then be the value of {{input}}. But then again, like I said above, I need to think if this is something that would actually be needed. Is there a use case for this? Would you find this useful in your workflows?

FelipeRearden commented 3 years ago

I 100% agree with you @Taitava.

That’s why is so important the relationship between developer and testers and users. In my country we have a say that “two heads thinks better than one”:

Classic Example: Search and Replace in Current File Imagine I have to always search for the phrase “Hello World” and replace with “hello friend” in a subset of notes.

I could use Shell Commands to create the expressions to:

Using the QuickAdd plug-in in can stack all commands in a MACRO and use a single hotkey to start the automation.

That’s why I love your plug-in so much. Now I can do things that Obsidian can’t

If you want I can bring more real examples to you.

—-

The {{input}} idea is fantastic and could fit into many workflows.

Let me think about it and I get back to you..

It’s always a pleasure talking to you. I always learn something when we talk.

Taitava commented 3 years ago

That’s why is so important the relationship between developer and testers and users. In my country we have a say that “two heads thinks better than one”

Thats true! We have a similar saying, it goes something like "Two pairs of eyes sees better than one pair".

Using the QuickAdd plug-in in can stack all commands in a MACRO and use a single hotkey to start the automation.

That plugin sounds interesting. I don't have much time to check it now, but maybe later. I just wanted to note that you can also chain multiple shell commands into one. For example in Linux you can use && operator (maybe its the same in Mac?) to "first execute one command, and if it succeeds, execute the next one". E.g. cd AnotherFolder && mkdir NewSubFolder && touch NewFile.md. (In Windows the operator is &).

If you want I can bring more real examples to you.

I think I understood this example quite well, it's a good one 🙂 . Nice that Mac has a command to emulate the keyboard. I do not know if Windows/Linux has those, maybe?

P.S. {{workspace}} variable is now implemented and will come out with version 0.3.0 sometime soon. 😉

It’s always a pleasure talking to you. I always learn something when we talk.

Same with you!

FelipeRearden commented 3 years ago

Different words and the same meaning :)

I think you gonna like QuickAdd . It’s a great companion to Shell Commands.

Wow ‘&&’ looks amazing. I didn’t know and I’m gonna try

Yes it’s amazing.didn’t know about Apple script since 2 months ago. I’m almost sure that there is something for Windows too.

Thank you very much for the new {{variable}} !!!!!!!

As I can see we will have many talks about this amazing plug-in in the next few days and weeks !

So, we talk soon @Taitava !

Have a great day!

Taitava commented 3 years ago

Thank you! 🙂

I'm thinking about opening a Discussions section here in GitHub. Then we can better separate idea discussions from already decided, to be implemented features (= issues). I haven't used Discussions before in my own repositories, but I've used it just a little bit in Dataview's GitHub repo.

Some general principles:

I'll close this issue now, as the two variable related things are now done and waiting for a release. Have a great day too! 🙂

Taitava commented 3 years ago

And when you talked about workflow ideas earlier, in the Discussion section there is a "Show and tell" category where you can post ideas about use cases for this plugin. 🙂

FelipeRearden commented 3 years ago

It's a fantastic idea @Taitava !!!!

100% agree with you ! Now we can have a place to brainstorm our ideas, help wanted, and share experiences and workflow.

100% agree with you about the general principles!

:)

FelipeRearden commented 3 years ago

By the way...

For example in Linux you can use && operator (maybe its the same in Mac?) to "first execute one command, and if it succeeds, execute the next one". E.g. cd AnotherFolder && mkdir NewSubFolder && touch NewFile.md. (In Windows the operator is &).

&& is the operator for MacOS - worked fantastic in one of my Shell Commands.

Thank you for the help :)

Taitava commented 3 years ago

You are welcome! 🙂

I think I'm gonna release 0.3.0 maybe today or at least soon. There is one thing I'd like you to test with {{workspace}}: If you have just opened Obsidian, then there is no information about the current workspace (maybe your current workspace does not even look like one of your predefined workspaces). If you in this situation try to run a shell comand that uses the variable, the shell command will give you an error message: Could not figure out the current workspace's name. Probably you have not loaded a workspace. You can do it e.g. via "Manage workspaces" from the left side panel.

I'd just like to know if you think that this situation is a problem? In theory, I could change the variable to just return an empty text when there is no active workspace, but I don't feel that would be a correct way to go. I think that the user should be informed and the command cancelled.

P.S. There's no rush testing this after the release. 🙂

Edit: I just tested the {{workspace}} variable again, and this time it seemed to work even when I have just opened Obsidian and have not manually gone to "Manage workspaces" to load a workspace. Good. So let's just keep eyes open and report for example in a new issue if there are any problems with this variable in the future.

Taitava commented 3 years ago

And I forgot to ask you @FelipeRearden can you please provide an example command that uses {{workspace}} so I'll add it to the examples in README.md? Thanks! 🙂

Taitava commented 3 years ago

Now 0.3.0 is released and {{workspace}} can be tested any time. 🙂

FelipeRearden commented 3 years ago

Hello @Taitava !!!!!

There is one thing I'd like you to test with {{workspace}}

After reading your message and start to use the new variable I figured out something interesting that I didn't realize:

I don't know what happens if I delete all my workspaces, but I think the message is a good way to alert!

Edit: I just tested the {{workspace}} variable again, and this time it seemed to work even when I have just opened Obsidian and have not manually gone to "Manage workspaces" to load a workspace. Good. So let's just keep eyes open and report for example in a new issue if there are any problems with this variable in the future.

You are right. It's the type of thing that we have to start using to see if something happen :)

FelipeRearden commented 3 years ago

And I forgot to ask you @FelipeRearden can you please provide an example command that uses {{workspace}} so I'll add it to the examples in README.md? Thanks! 🙂

Copy to Clipboard an internal link alias with related workspace : printf "[[{{title}}|{{title}} -> {{workspace}}]]" | pbcopy

FelipeRearden commented 3 years ago

Now 0.3.0 is released and {{workspace}} can be tested any time. 🙂

Works perfect on MacOS !

Thank you very much!

Taitava commented 3 years ago

Works perfect on MacOS !

Thank you! I added the Mac test to README.md, using the same Obsidian version and OS version information as earlier.

Taitava commented 3 years ago

Copy to Clipboard an internal link alias with related workspace : printf "[[{{title}}|{{title}} -> {{workspace}}]]" | pbcopy

Is this just so that you simply want to add the workspace name to the link alias? Can you give an example of what the final link might look like, please? Thanks. 🙂

FelipeRearden commented 3 years ago

Sure!

I have one workspace for each book I'm reading:

Shell Command: [[LN | LN -> How to Take Smart Notes]] On Preview Mode (as a link): LN -> How to Take Smart Notes

Since I have LN for others books, I have to know with one is from each book :)


This is as work in progress: I'm thinking about creating Dashboard Notes to use as quick links to areas of my vault.

I don't yet what I want and I'm trying different approaches to see if it is something useful or not :)

Let me know if you want more info!

Have a great day!

Taitava commented 2 years ago

Thanks!

Copy to Clipboard an internal link alias with related workspace : printf "[[{{title}}|{{title}} -> {{workspace}}]]" | pbcopy

I added something like this to README.md.