rel:: [[PKM]] # Obsidian ## Reference - [Obsidian Online Help](https://help.obsidian.md/Obsidian/Index) - [Publish](https://help.obsidian.md/Obsidian+Publish/Introduction+to+Obsidian+Publish) - [Sync Guides](https://help.obsidian.md/Obsidian+Sync/Introduction+to+Obsidian+Sync) - [Initial Setup](https://help.obsidian.md/Obsidian+Sync/Set+up+Obsidian+Sync) - [Add A Device](https://help.obsidian.md/Obsidian+Sync/Add+another+device) - [Syncing notes across devices](https://help.obsidian.md/Getting+started/Sync+your+notes+across+devices) - [Why Can't you sync with X just like iA Writer?](https://help.obsidian.md/Getting+started/Sync+your+notes+across+devices#Why+can't+I+sync+using+X) - Advanced - [Using obsidian URI](https://help.obsidian.md/Advanced+topics/Using+obsidian+URI) - [Obsidian Hub](https://publish.obsidian.md/hub/) - [Obsidian Docs Repository](https://github.com/obsidianmd/obsidian-docs) - [customize icon](https://obsidian.md/blog/new-obsidian-icon/) ### Plugin Development - [Obsidian Plugin Developer Docs](https://marcusolsson.github.io/obsidian-plugin-docs/) - [Liam Cain's API Docs](https://publish.obsidian.md/liam/Obsidian/Vault) - [Getting Started by Ryan Murphy](https://forum.obsidian.md/t/plugins-mini-faq/7737/26?u=ryanjamurphy) - [Class for getting plugins from the registry](https://github.com/zephraph/obsidian-tools/blob/main/packages/obsidian-utils/src/plugin/registry.ts) - [tools for installing a plugin from the registry or fs](https://github.com/zephraph/obsidian-tools/blob/main/packages/obsidian-utils/src/plugin/install.ts) - [getting meta info on local plugins](https://github.com/zephraph/obsidian-tools/blob/main/packages/obsidian-utils/src/plugin/local.ts) - [build tool for obsidian plugins that uses esbuild](https://github.com/zephraph/obsidian-tools/tree/main/packages/obsidian-plugin-cli) - [pjeby/hot-reload](https://github.com/pjeby/hot-reload) - [hub notes on plugin dev](https://publish.obsidian.md/hub/04+-+Guides%2C+Workflows%2C+%26+Courses/for+Plugin+Developers) - [obsidian-dev-tools](https://github.com/KjellConnelly/obsidian-dev-tools) plugin to get a console on mobile - [utility functions](https://github.com/obsidian-community/obsidian-community-lib/blob/main/src/utils.ts) - just grab what you need, pls don't add yet another 3rd party dependency for a 3-line utility - testing examples - https://github.com/schemar/obsidian-tasks - hooks to lint and test on git actions - https://github.com/kometenstaub/linked-data-helper - uses golden files ### Templates - [[Template/article]] - [[Template/daily]] - [[Template/incident review]] - [[Template/person]] - [[Template/service]] - [[Template/MOC]] ## Plugins - [[Templater]] ## Mobile ### Useful Plugins shortcut dependencies * [NL Dates Plugin](https://github.com/argenos/nldates-obsidian) * [Advanced URI Plugin](https://github.com/Vinzent03/obsidian-advanced-uri) ### Shortcuts [forum index](https://forum.obsidian.md/t/ios-shortcuts-share-your-ideas/15149) #### Best Of * [append selected to DNP](https://www.icloud.com/shortcuts/37a448f5c94a42d39091d99f7f0d166f) * [daily notes shortcut](https://www.icloud.com/shortcuts/d441152cb2604cb6916ffa892b55d24e) ## Publish ### Publish API server address This may vary depending on site. ```bash jq -r '.host' $VAULT_ROOT/.obsidian/publish.json ``` ### Running the _Publish Changes_ action 1. requests list of previously published files: `POST https://publish-01.obsidian.md/api/list`. - response: `{"files":[{"path":"publish.css","hash":"071e0f478ba4ac..."},...]}` 2. compares hashes with local files to determine what files need updated ### Client-side Rendering When visiting a publish site - Obsidian _Reading View_ in safe mode should approximate Publish results in fidelity. - The site HTML is just a content container loaded from either https://publish.obsidian.md or [via proxy](https://help.obsidian.md/Obsidian+Publish/Set+up+a+custom+domain) for a custom domain. - a stripped down version of Obsidian loads from `https://publish.obsidian.md/app.js?<version?>` - the client-side publish app fetches the published markdown for each note on-demand from the site's [[#To find your publish API server address|publish API server]]. There is no opportunity to intercept this [via proxy](https://help.obsidian.md/Obsidian+Publish/Set+up+a+custom+domain) as the request goes directly to `publish-XX.obsidian.md` ## Sync With [Sync](https://obsidian.md/sync), Obsidian is a local-first note taking system that syncs across all your devices for $8/mo. The developers happen to give away the software for free, but people that pay for the sync service (and publish) are the ones actually subsidizing development. They could pay-wall the whole thing. They aren’t. Similarly, Github charges a large premium for SSO. Only large enterprises require this relatively small feature compared to the rest of all the services Github provides for free or nearly free to everyone else. Enterprises that can afford to pay are subsidizing Github’s services for everyone else. ## Meta ### Tech Stack #### Desktop - [Electron](https://www.electronjs.org) - [[TypeScript]] - [node.js](https://nodejs.org/) ##### Mobile - [capacitor.js](https://capacitorjs.com) - _Capacitor is an open source native runtime for building Web Native apps. Create cross-platform iOS, Android, and Progressive Web Apps with JavaScript, HTML, and CSS._ ### Philosophy, Making Obsidian - [Interview with silver, nesslabs](https://nesslabs.com/obsidian-featured-tool) - [Interview with licat on community building](https://robhaisfield.com/notes/building-community-in-obsidian-with-licat) - [[202204181144 Licat on Obsidian Philosophy]] - [[202203270003 Licat on Obsidian Sync Security|Professional consultation on Obsidian Sync encryption]] ([[202203270003 Licat on Obsidian Sync Security#^b5e6cb|source]]) ## Recipes ### Obsidian Publish naked embeds https://github.com/obsidian-tasks-group/obsidian-tasks/blob/067f50d228d34797cbf633b408a8c8a12edfd247/docs/publish.css#L96-L120 ### Embedded HTML ```html To create a new file, choose the menu option <kbd><kbd><samp>File</samp></kbd>⇒<kbd><samp>New Document</samp></kbd></kbd>. <kbd>Cmd</kbd>+<kbd>O</kbd> => <kbd><samp>Open</samp></kbd> <progress max="100" value="70">70%</progress> ``` > [!INFO] Renders as > > To create a new file, choose the menu option > <kbd><kbd><samp>File</samp></kbd>⇒<kbd><samp>New > Document</samp></kbd></kbd>. > > <kbd>Cmd</kbd>+<kbd>O</kbd> => <kbd><samp>Open</samp></kbd> > > <progress max="100" value="70">70%</progress> ### Super/Subscript ``` $H_{2}O$ - LaTeX ``` $H_{2}O$ - LaTeX ```html H<span style="vertical-align: sub; font-size: smaller;">2</span>O - HTML log<sub>n</sub>(x<sup>n</sup>) ``` H<span style="vertical-align: sub; font-size: smaller;">2</span>O - HTML log<sub>n</sub>(x<sup>n</sup>) ### Font Vars as of 0.14.4 ```css body { --font-default: var(--default-font, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Microsoft YaHei Light", sans-serif); --font-interface-override: ''; --font-interface-theme: ''; --font-interface: var(--font-interface-override), var(--font-interface-theme), var(--font-default); --font-text-override: ''; --font-text-theme: ''; /* editor and reading font*/ --font-text: var(--font-text-override), var(--font-text-theme), var(--font-interface); --font-monospace-override: ''; --font-monospace-theme: ''; --font-monospace: 'Source Code Pro', monospace; --font-text-size: 16px; --font-mermaid: var(--font-text); } ``` ### Query ```` ```query line:("1 Chronicles" -previous -next) ``` ```` ### Add Extra Search Pane to Right Side Bar ```javascript app.workspace.getRightLeaf().setViewState({type: 'search'}); ``` As `type: search` does not have a Close context menu, open `.obsidian/workspace` and remove the search panel from the right side bar to close. ### [[Obsidian]] vim window controls > [!NOTE] > As of [[2022-03-14]], release 0.14.0, this hack is no longer needed. [[licat]] modified the included `vim.js` so `C-w` leader shortcuts are supported natively. > > To enable vim-native `C-w` window manipulation. > > 1. Make sure the `Ctrl-W` hotkey is removed for `Open Settings / Hotkeys > Close active pane` > 2. Install the [obsidian-vimrc-support plugin](obsidian://show-plugin?id=obsidian-vimrc-support). > 3. Add the following to `<VAULT_ROOT>/.obsidian.vimrc` ^2d0825 ``` " window controls exmap wq obcommand workspace:close exmap q obcommand workspace:close exmap focusRight obcommand editor:focus-right nmap <C-w>l :focusRight exmap focusLeft obcommand editor:focus-left nmap <C-w>h :focusLeft exmap focusTop obcommand editor:focus-top nmap <C-w>k :focusTop exmap focusBottom obcommand editor:focus-bottom nmap <C-w>j :focusBottom exmap splitVertical obcommand workspace:split-vertical nmap <C-w>v :splitVertical exmap splitHorizontal obcommand workspace:split-horizontal nmap <C-w>s :splitHorizontal ``` - [For reasons TBD (question in pull request)](https://github.com/codemirror/CodeMirror/pull/5711#issuecomment-1064514227) - best guess is `C-w` is a common window close shortcut - CodeMirror's vim support has `<C-w>` [explicitly disabled](https://github.com/codemirror/CodeMirror/blob/7f702332fe32efa177063a54c2d5e5e2a4b7d84f/keymap/vim.js#L186-L187) in normal mode - [as discussed on an issue](https://github.com/esm7/obsidian-vimrc-support/issues/67) filed against the [obsidian-vimrc-support plugin](obsidian://show-plugin?id=obsidian-vimrc-support) patch that needs applied to `lib/codemirror/vim.js` ```diff --- vim.js 2022-03-10 00:54:21.000000000 -0500 +++ vim.js 2022-03-10 01:02:05.000000000 -0500 @@ -183,7 +183,7 @@ { keys: '<C-u>', type: 'operatorMotion', operator: 'delete', motion: 'moveToStartOfLine', context: 'insert' }, { keys: '<C-w>', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, //ignore C-w in normal mode - { keys: '<C-w>', type: 'idle', context: 'normal' }, + //{ keys: '<C-w>', type: 'idle', context: 'normal' }, // Actions { keys: '<C-i>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, { keys: '<C-o>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, ``` To patch `obisidan.asar` (see [[cli#diff and patch]]) ```bash MAIN_ASAR=/Applications/Obsidian.app/Contents/Resources/obsidian.asar CACHE_DIR="/Users/$USER/Library/Application Support/obsidian" TARGET_ASAR=$((ls -r "$CACHE_DIR"/obsidian-*.asar 2>/dev/null || echo "$MAIN_ASAR") | head -n 1) TMP_ASAR=/tmp/obsidian.asar UNPACKED_ASAR=/tmp/obsidian.asar.unpacked TARGET_VIMJS=$UNPACKED_ASAR/lib/codemirror/vim.js # cleanup rm -rf $TMP_ASAR $UNPACKED_ASAR npx asar extract "$TARGET_ASAR" /tmp/obsidian.asar.unpacked # DOS->unix sed -i s/\r'$// $TARGET_VIMJS cat <<EOF | patch -r /dev/null -N $TARGET_VIMJS || true --- vim.js 2022-03-10 00:54:21.000000000 -0500 +++ vim.patched.js 2022-03-10 01:02:05.000000000 -0500 @@ -183,7 +183,7 @@ { keys: '<C-u>', type: 'operatorMotion', operator: 'delete', motion: 'moveToStartOfLine', context: 'insert' }, { keys: '<C-w>', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, //ignore C-w in normal mode - { keys: '<C-w>', type: 'idle', context: 'normal' }, + //{ keys: '<C-w>', type: 'idle', context: 'normal' }, // Actions { keys: '<C-i>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, { keys: '<C-o>', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, EOF npx asar pack $UNPACKED_ASAR $TMP_ASAR # replace with patched asar pkill Obsidian cp $TMP_ASAR "$TARGET_ASAR" ``` #### Current obsidian.vimrc Setup [Obsidian Vim Support](obsidian://show-plugin?id=obsidian-vimrc-support) to use `obsidian.vimrc` instead of `.obsidian.vimrc` so [[#Sync]] picks it up. ```vimrc " commenting out the visual line navigation out as it fails navigating notes with embeds "" Have j and k navigate visual lines rather than logical ones, normal mode ""noremap j gj ""noremap k gk ""noremap gj j ""noremap gk k " "" use logical line navigation in visual mode ""vnoremap j gj ""vnoremap k gk ""vnoremap gj j ""vnoremap gk k " clear highlights nmap <F5> :nohl " Emulate Original gt and gT https://vimhelp.org/tabpage.txt.html#gt exmap nextTab obcommand workspace:next-tab exmap prevTab obcommand workspace:previous-tab nmap gt :nextTab nmap gT :prevTab " Emulate Original Folding command https://vimhelp.org/fold.txt.html#fold-commands exmap unfoldall obcommand editor:unfold-all exmap togglefold obcommand editor:toggle-fold exmap foldall obcommand editor:fold-all exmap foldless obcommand editor:fold-less exmap foldmore obcommand editor:fold-more nmap zo :togglefold nmap zc :togglefold nmap za :togglefold nmap zm :foldmore nmap zM :foldall nmap zr :foldless nmap zR :unfoldall " spell check exmap contextMenu obcommand editor:context-menu nmap z= :contextMenu vmap z= :contextMenu exmap wq obcommand workspace:close exmap q obcommand workspace:close exmap focusRight obcommand editor:focus-right nmap <C-w>l :focusRight exmap focusLeft obcommand editor:focus-left nmap <C-w>h :focusLeft exmap focusTop obcommand editor:focus-top nmap <C-w>k :focusTop exmap focusBottom obcommand editor:focus-bottom nmap <C-w>j :focusBottom exmap vsplit obcommand workspace:split-vertical nmap <C-w>v :vsplit exmap split obcommand workspace:split-horizontal nmap <C-w>s :split " Yank to system clipboard set clipboard=unnamed set tabstop=4 ```