UNPKG

@huangjunsen/vault-cli

Version:

macOS vault CLI: hide/unhide directories with .noindex and manage encrypted sparsebundles

37 lines (31 loc) 952 B
const fs = require('fs'); const path = require('path'); const os = require('os'); const { run, printInfo } = require('./utils'); function clearQuickLookCache() { try { run('qlmanage', ['-r', 'cache']); } catch (e) { // On some systems, qlmanage may return non-zero even if it resets; ignore. } } function clearRecentDocuments() { const sflDir = path.join(os.homedir(), 'Library', 'Application Support', 'com.apple.sharedfilelist'); if (!fs.existsSync(sflDir)) return; const entries = fs.readdirSync(sflDir); for (const f of entries) { if (f.startsWith('com.apple.LSSharedFileList.RecentDocuments')) { const fp = path.join(sflDir, f); try { fs.rmSync(fp, { force: true }); } catch {} } } } function rebuildSpotlightIndexAll() { // Expensive: re-index entire system volumes run('mdutil', ['-E', '/']); } module.exports = { clearQuickLookCache, clearRecentDocuments, rebuildSpotlightIndexAll, };