MH Recent Files

unlisted

by MH - Matheus Heidemann

Shows recently opened, modified, and created files in Obsidian sidebar panels, a quick access modal, and embeddable code blocks.

Updated 1mo ago
View on GitHub

MH Recent Files

Summary

MH Recent Files is an Obsidian plugin that tracks recently opened, modified, and created files. It provides sidebar panels, a quick access modal, an embeddable mh-recent-files code block, path/file exclusions, localization, and a small public API for other plugins.

Purpose And Features

  • Track recently opened, modified, and created files independently.
  • Show three Obsidian sidebar panels: opened, modified, and created.
  • Open a quick access modal with tabs, search, sorting, and per-type clear actions.
  • Embed recent files in notes with a fenced mh-recent-files code block.
  • Respect Obsidian ignored files, custom exclusions, or both.
  • Exclude specific extensions, files, and folders.
  • Configure list limits separately for stored history, sidebar panels, and the modal.
  • Display either the current folder or full path.
  • Optionally truncate long names in sidebar/modal lists.
  • Load UI strings from locales/en-us.json and locales/pt-br.json.

How It Works / How To Use

The plugin listens to Obsidian file events and stores timestamps for each tracked file:

  • file-open updates the opened timestamp.
  • modify updates the modified timestamp.
  • create updates the created timestamp.
  • rename keeps existing history attached to the renamed file.
  • delete removes the deleted file from history.

Use the command palette:

  • Toggle recent files sidebar
  • Open recent files modal
  • Clear recent files history

The sidebar can be enabled or disabled in settings and placed on the left or right side. The modal can also be enabled or disabled. Search filters by file name or path, and sorting can be toggled between newest-first and oldest-first.

Settings available:

  • Language: select a locale from the locales/ folder.
  • Tracking: enable or disable opened, modified, and created tracking.
  • History limits: set independent maximum stored counts for opened, modified, and created files.
  • Display: choose current-folder path display or full-path display; optionally truncate names.
  • Exclusions: ignore extensions, custom files/folders, Obsidian ignored files, or a combined rule set.
  • Sidebar: enable, side, and maximum visible items per list.
  • Modal: enable and maximum visible items.
  • Actions: clear all tracked history.

Exclusion modes:

  • obsidian: only Obsidian ignored-file filters are applied.
  • custom: only this plugin's excluded paths are applied.
  • combined: both Obsidian ignored-file filters and custom exclusions are applied.

Custom path exclusion rules:

  • Folder exclusions end with /, for example Templates/.
  • File exclusions use the exact vault path, for example Archive/Old note.md.
  • Extension exclusions are comma-separated, for example png,jpg,pdf. A leading dot is accepted and normalized.

MH Recent Files does not read note frontmatter. For inline rendering, use a fenced code block:

```mh-recent-files
show: opened, modified, created
layout: columns
limit: 5
show-header: true
show-time: true
show-path: true
```

Code block options:

  • show: comma-separated list of opened, modified, and created. Disabled tracking types are hidden even if listed.
  • layout: columns or rows.
  • limit: maximum items per section.
  • show-header: true or false.
  • show-time: true or false.
  • show-path: true or false.

Practical examples:

```mh-recent-files
show: opened
layout: rows
limit: 10
show-path: false
```
```mh-recent-files
show: modified, created
layout: columns
limit: 3
```

Other plugins can read the public API from window.MhRecentFilesAPI:

const api = window.MhRecentFilesAPI;
const opened = api.getRecentlyOpened(10);
const unsubscribe = api.onChange((items) => console.log(items.length));

Installation

Manual installation requires these files in .obsidian/plugins/mh-recent-files/:

  • main.js
  • manifest.json
  • versions.json
  • locales/en-us.json
  • locales/pt-br.json

Do not copy src/, node_modules/, or data.json for normal plugin installation. main.js is generated by the TypeScript build and is the runtime bundle Obsidian loads.

Development

Install dependencies:

npm install

Run a watch build during development:

npm run dev

Run TypeScript validation:

npm run typecheck

Create the production bundle:

npm run build

Validate the generated bundle syntax:

node --check main.js

Source code lives in src/. The build entrypoint is src/main.ts, and the generated output is main.js. The Obsidian API package is kept external in the bundle.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.