Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
FelipeRearden opened this issue Sep 15, 2021 · 20 comments
Closed

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

FelipeRearden opened this issue Sep 15, 2021 · 20 comments

Comments

@FelipeRearden
Copy link

@FelipeRearden FelipeRearden commented Sep 15, 2021

Hello again @Taitava !!!

I'd like to ask you about Variables:

  • Did you create the variables for your plug-in or these variables are from Obsidian API ?
  • Is it possible to create a feature request to add new variables ?

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

  • it is just an idea now, but I decide to check you before deep dive.

Have a great day !!!!

@Taitava
Copy link
Owner

@Taitava Taitava commented Sep 15, 2021

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! 🙂

  • {{file_name}} without .md has another variable which might be a bit confusing: {{title}}. I think I'll need to add to the description of {{file_name}} that if user wants the name without the extension, then use {{title}}.
  • {{workspace}}: Good idea! I have not used workspaces in Obsidian, so I'm not familiar with them. In #6 you had a shell command in the command palette screenshot that used &workspace=WK1. Should {{workspace}} variable give the current workspace's name, for example WK1?

Todo:

  • Add to the description of {{file_name}} that if user wants the name without the extension, then use {{title}}.
  • Create {{workspace}} variable.

@FelipeRearden
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 15, 2021

This is amazing @Taitava !!!

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

  • Thanks for letting us create FR for variables too!

  • Sorry about {{title}}: It was my mistake but a warning in the text for the user would be great .

  • You are 100% correct about {{workspace}}

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
Copy link
Owner

@Taitava Taitava commented Sep 15, 2021

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 15, 2021

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”:

  • everybody has your own way of life, principles, experiences and together we can make a product better. :)

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:

  • copy Hello Friend to clipboard
  • Paste in the find field
  • Press tab to focus on the replace field
  • Copy hello friend to the clipboard
  • Paste
  • Press enter

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

  • Search and Replace in Current File
  • Shell Command 1
  • Shell Command 2
  • Shell Command 3 ....

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

  • A new world opens to me.

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

—-

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

  • I’m thinking about a list of inputs to let the user choose with one is going to be the {{input}}

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 added a commit that referenced this issue Sep 15, 2021
@Taitava
Copy link
Owner

@Taitava Taitava commented Sep 15, 2021

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 15, 2021

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

  • I could copy to clipboard, copy than paste with one command
  • Thanks for the help :)

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
Copy link
Owner

@Taitava Taitava commented Sep 16, 2021

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:

  • If you encounter a bug and you are pretty certain it is a bug, you can still open a new issue directly.
  • If you have a feature request that is quite simple and that has clear benefits and probably does not require much discussion about how it should look like from the user's perspective, you can still open a new issue directly.
  • If you are unsure whether a problem you encountered is a bug or if it could be solved with better guidance/documentation, then open a new discussion. Of course for clear documentation errors (README.md or in application guidance) you can open an issue directly.
  • If you have a feature request, but you are unsure how it should finally work, or unsure if it's possible to create, or you feel that it might otherwise need extensive discussion before implementation, then open a new discussion.
  • Discussions can always be transformed into issues, if we later decide that a discussion should lead to concrete development.
  • Also issues can be transformed into discussions.

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
Copy link
Owner

@Taitava Taitava commented Sep 16, 2021

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 16, 2021

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!

  • Much easier to separate the inputs to the plug-in

:)

@FelipeRearden
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 16, 2021

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
Copy link
Owner

@Taitava Taitava commented Sep 17, 2021

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
Copy link
Owner

@Taitava Taitava commented Sep 17, 2021

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
Copy link
Owner

@Taitava Taitava commented Sep 17, 2021

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

@FelipeRearden
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 17, 2021

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:

  • after using workspaces, I'm always in a workspace. Besides switching from workspaces, I don't know how exit a workspace.

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 17, 2021

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 17, 2021

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

Works perfect on MacOS !

Thank you very much!

@Taitava
Copy link
Owner

@Taitava Taitava commented Sep 18, 2021

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
Copy link
Owner

@Taitava Taitava commented Sep 18, 2021

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
Copy link
Author

@FelipeRearden FelipeRearden commented Sep 18, 2021

Sure!

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

  • Workspace: How to Take Smart Notes
  • Note: LN [means Literature Notes]

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
Copy link
Owner

@Taitava Taitava commented Sep 20, 2021

Thanks!

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

I added something like this to README.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants