Which tool to use to create a custom command

After coding this answer, where I use Templater to build a suggester of files with file aliases, ala Quick Switcher, I want to build a command which either chooses an existing file or creates a new file. But the question I would like some input on is: Where (and with which plugin) would you use to create a custom command?

So far I’ve used either Templater based commands, or variants of QuickAdd script, but this time I’m aiming for a command which should do three things:

  • Have a suggester to choose a potential existing file name (or store the new file name suggestion)
  • If existing, triggering an open file command (from some API)
  • If not existing, trigger a Templater tp.file.create_new()

So what tool would you use to create such a command? I would like for it to be assigned a hotkey, and to be able to trigger it without necessarily having an open file (which kind of rules out Templater ).

Note that I’m not asking about coding the command, just how and where to put the code which eventually creates the command within a suitable environment for me to continue from. (Although a suggestion on which command to use to open a file is appreciated :slight_smile: )

As stated Templater is most likely ruled out since I then need to have an active editor, and I don’t really like the convoluted way of defining commands through QuickAdd (with a choice, having a macro, linked to a function file, and then configured to trigger that function… ).

1 Like

This has gained a lot less traction than I hoped to, so let me try to increase the traffic by describing some of the mixture of tools I’m currently using:

  • dv.view()-scripts for some more Dataview related stuff
  • Templater user functions for the more specific Templater stuff
  • Some odd-ball CustomJS functions, but haven’t made an transition into using that
  • Some QuickAdd javascript functions, but for my needs it feels a little convoluted as it requires a lot of steps to trigger any of my custom commands
  • I’ve even tried a slightly older User Plugins which allows to do custom commands either in javascript files, or through snippets in its settings section. Kind of like the concept of this one

I’ve also contemplated on using the Startup template of Templater to create commands, or “misusing” dataviewjs or similar. But I’m a little worried on how to handle command updates/modification and so on.

I’ve not used RunJS, JavaScript Init, JS Engine or Run, although I’ve heard of them. I’ve neither tried the likes of Code Emitter or Inline Scripts or Modules (or Micro templates).

I’m trying out VSCode editor, which should get an update to eliminate a rather noisy console issue (which can be hidden/ignored though), and this plugin allows me to do rather nice javascript and CSS editing within Obsidian. I’m not eager to use Code Files due to its online dependency, and the implications of that dependency.

2 Likes

So far my usage is 95 percent Templater Js and 5 percent QuickAdd (for stuff I saw on the internet).

Inline Scripts I tried (to look into), but the RPG theme and the default srcipts were too out of line with my use cases.

I’d like to use the DVJs oneliners with dv.view but they they throw the promise error (or on await I get - as “result”).