Plugin: Slash Commands - Datetime & More

The last essential plugin for my workflow which I rush a little bit to be in time for new year resolution. There are still a lot of plugins in my backlogs but they all nice-to-have features so I will not develop any of them soon.

Slash Commands is a collection of utility commands that can be executed by typing corresponding keywords, which start with a slash ('/'). Current version only supports two type of commands (string and datetime) but more might be added in the future.

screencap

You can define your own commands but it can be tricky so please check github README. This plugin will be a great companion with my other plugin for task management:

14 Likes

Updated v1.1.0

Added Calendar Command that print an ascii calendar. It is quite a niche utility so not sure if anyone else beside me want one.

      December 2021       
Su  Mo  Tu  We  Th  Fr  Sa
             1   2   3   4
 5   6   7   8   9  10  11
12  13  14  15  16  17  18
19  20  21  22  23  24  25
26  27  28  29  30  31

If you already edit the plugin setting the update will not able to add the new command by itself so you have to manually add calendar command to your setup

["calendar", "calendar", [null,"en-US","ja-JP"] ]

Or you can check github page and copy the default command definitions.

You can print calendar of the current month or any specified month by typing /calendar-m-yyyy

7 Likes

Thanks for this and all your other plugins. I'm not sure how I would use this, but it looks like it could be handy.

1 Like

This is awesome, but basing the beginning of the week on the locale has always been bullshit. I am not saying this is your fault, I'm just saying this is a gerneral problem. e.g. I am in Canada and according to the locale info the week starts on Sunday. Well, this might be, but I start work on Monday and work until Friday, so my week starts on Monday.
Whoever came up with Sunday as the start of the week must have been related to the idiots who thought that miles and Fahrenheit are great and useful units.

The only time it makes sense to use Sunday as the start of the week is in countries in the Middle East.

Long story short, it should not be based on the locale but on a parameter.

3 Likes

I see. I did saw some debate about that but a week starts in Sunday or Monday never actually bothers me that much, and I use several different locales across devices, so I just go with whatever that requires the less effort from me.

The current locale parameter is actually used to translate the month and weekdays to the respectable language. I will consider that as a configurable parameter for future update but as this is quite a niche utility it's priority will not be very high.

Don't worry about it. It was rather meant as a general comment.

I would certainly appreciate a parameter for setting the beginning of the week, but I do understand that the priority for that is low. All good. Great plugin.

PS: Btw, as an idea (also not important). How about using // for getting a list of all commands in the command palette (and then use autocomplete search)? Not sure how useful that is though...

Updated v1.2.0

Add support for Datetime Command Weekday Query so you can get date of a specific day of week by add a keyword to your command. For example

/date@mon        # Next Monday (exclude today)
-> 17/01/2022
/date@mon-1      # Last Monday (or today)
-> 10/01/2022

Supported keywords are: @1 or @sun for Sunday, @2 or @mon for Monday, @3 or @tue for Tuesday, @4 or @wed for Wednesday, @5 or @thu for Thursday, @6 or @fri for Friday, @7 or @sat for Saturday.

Just update the plugin and all datetime commands will support this feature.

3 Likes

@hieuthi Thank you for the plugin. I've installed it, and I appreciate the fact that I can input solely using the keyboard - there is no longer a need to use mouse as an input device for things like dates, etc.

I have some comments I hope you'll respond to. If discussion reaches the point you'd like me to open some Github issues and provide UI designs, please let me know.

Discovering possible commands is difficult

I installed it and understand the command syntax begins with '/' like Notion. However unlike Notion I don't know what commands are available. And to find out what they are, I need:

  • go to preferences
  • go to plugins -> slash commands
  • So then I need to find the Github repo README, which is also not completely clear to me

Possible solution

Is it possible for all commands/example command syntax to be displayed when the user hits '/'? Similar to how it works in Notion:

This would also save the need for indepth documentation (at the beginning at least)

Extend possible commands

What is possible to achieve with the '/' command? Would it be possible to extend the commands to allow actions?

Example: Add image to note via / command

Would it be possible to something like this?

1 Like

I do have this feature in my backlog but I don't have a lot of time recently. Feel free to open an issue on github so I will remember it when I secure some free time for hobby project.

This feature is too elaborated and you also end up have to use mouse so I don't think a slash command will add much benefit. So I don't think I will ever implement it.

[v1.3.0] - 2022-12-09

Changed

  • Changed the way setting is loaded

Added

  • Add i18n support for datetime commands
  • Add hinting for the commands themselves
  • Restore definitions to default if setting is blank
3 Likes

Are there plans to add optional autocomplete?

/ shows all commands, but completing an incomplete top-level command with Tab, Enter, or mouse click returns the command (for example, /now), not the result nor submenu.

It's in my backlog for quite a long time but never had time to implement it (I still decide to show the commands as some kind of suggestion). We see if I can implement it in this holiday season.

I am open for pull request for this particular feature btw. If you know some simple way to achieve that feel free to make a PR on github.

Publish new version that supports CodeMirror6 (default engine for the latest Joplin version), thanks @personalizedrefrigerator .
The CM6 version also solved the problem with 2-step completion so I will not code that feature for the old CM5 version.

[v1.4.0] - 2024-09-24

Changed

  • Support CodeMirror6 (@personalizedrefrigerator)
  • Support 2 steps completion thanks to CodeMirror6 (@personalizedrefrigerator)
  • Add Space as a close character
3 Likes

I've just discovered this plugin and love it - particularly the customization. I've noticed that it doesn't appear when searching for plugins on mobile - is there a reason why?