A module-based Obsidian plugin that provides helpful slash commands for quick text insertion.
- Function: Inserts the current date at the cursor position
- Usage: Type
/today
in any note and it will be automatically replaced with today's date - Configurable: Date format can be customized in settings
- Function: Inserts the current time at the cursor position
- Usage: Type
/now
in any note and it will be automatically replaced with the current time - Configurable: Time format can be customized in settings (defaults to 24-hour format)
Command | Description | Example Output |
---|---|---|
/today |
Insert current date | 2024-01-15 (default format) |
/now |
Insert current time | 23:11 (default format) |
Access the plugin settings through Obsidian's Settings > Community Plugins > Slash Commands.
- Enable /today command: Toggle to enable/disable the
/today
slash command - Today date format: Customize the date format using moment.js format patterns
- Enable /now command: Toggle to enable/disable the
/now
slash command - Now time format: Customize the time format using moment.js format patterns (default: HH:mm)
YYYY
- 4-digit year (2024)MM
- 2-digit month (01-12)DD
- 2-digit day (01-31)MMMM
- Full month name (January)Do
- Day with ordinal suffix (1st, 2nd, 3rd, 4th)dddd
- Full day name (Monday, Tuesday, etc.)HH:mm
- 24-hour time formath:mm A
- 12-hour time format with AM/PM[text]
- Literal text (e.g.,[Today is] dddd
→ "Today is Monday")
YYYY-MM-DD
→ 2024-01-15DD/MM/YYYY
→ 15/01/2024MM/DD/YYYY
→ 01/15/2024MMMM Do, YYYY
→ January 15th, 2024dddd, MMMM Do
→ Monday, January 15thYYYY-MM-DD HH:mm
→ 2024-01-15 14:30[Today is] dddd
→ Today is Monday
HH:mm
→ 23:11 (24-hour format, default for /now)h:mm A
→ 11:11 PM (12-hour format with AM/PM)HH:mm:ss
→ 23:11:45 (24-hour with seconds)h:mm:ss A
→ 11:11:45 PM (12-hour with seconds)[Time: ]HH:mm
→ Time: 23:11 (custom text + time)
For more format options, see the moment.js documentation.
The plugin uses a modular approach with two main components:
- Real-time Detection: Automatically detects when you type slash commands and replaces them
- Manual Command: Access commands through Obsidian's command palette (Ctrl/Cmd + P)
- Copy the plugin files to your
.obsidian/plugins/obsidian-commands/
directory - Enable the plugin in Obsidian's Community Plugins settings
- Configure the settings as desired
This plugin is built using a module-based architecture instead of classes, making it easier to extend and maintain.
src/main.ts
- Main plugin logic and slash command handlingsrc/settings.ts
- Settings interface and configurationstyles.css
- Plugin styling
To add a new slash command:
- Add the command configuration to the settings interface
- Implement the command logic in the main plugin file
- Add the command detection in the
handleSlashCommand
function
MIT License