[Obs#56] 快速新增靈感/閃念筆記(Fleeting Note)的3種方法

tp.web.random_picture|600x300

我們偶爾會有靈光一閃、稍蹤即逝的絕妙想法,這些突發奇想何時會出現無從循跡、無法臆測,靈感來無影去無蹤,我們必須在最短的時間、用最快的方法將之記錄起來,以下介紹使用Obsidian將靈感快速新增成為筆記的方法。

第一種方法是立即建立一篇筆記。
第二個方法是直接新增到每日筆記,並將之變成待辦事項。
第三個方法是使用AutoHotkey在外部直接輸入文字再插入Obsidian對應位置。macOS的使用者請試試AppleScript或Alfred等方法來達成。

主要使用到的外掛如下:

  • Templater
  • QuickAdd
  • Advanced Obsidian URI (URI: 統一資源標識符)

建議

靈感/閃念筆記應該在一天或兩天裡清理掉(整理、合併到永久筆記或刪除),以免又形成另一個資料垃圾場。

方法1. 建立靈感筆記

使用QuickAdd新增一個Template的Choice,並設定一個快捷鍵。輸入靈感文字後會產生同名的筆記。

操作步驟

  1. QuickAdd選項→新增Template: Fleeting note的Choice
  2. 指定【Template path】為「模板資料夾/templater-fleeting-note.md」
  3. 勾選【File Name Format】,【File Name】欄位輸入「{{VALUE:靈光一閃}}」
  4. 【Create in folder】指定資料夾為「030-Inbox」

templater-fleeting-note.md

---
created: [ < tp.date.now("YYYY-MM-DD HH:mm") > ]
aliases: [ < tp.file.title > ]
tags: [ fleeting, todo ]
---
# <% tp.file.title %>

Modified:: <%+ tp.file.last_modified_date() %>

<% tp.file.title %>

<% await tp.system.clipboard() %>

缺點

生成了一個新檔案,最後需要刪除或搬移等檔案操作

方法2. 輸入內容後新增到每日筆記

此方法適用有使用Obsidian每日筆記與任務管理的狀況。在彈出視窗輸入內容後直接插入每日筆記指定標題處。

操作步驟

  1. QuickAdd選項→新增Capture: Fleeting note的Choice
  2. 指定【File Name】欄位為「020-Daily/{{DATE:YYYY-MM-DD_ddd}}」
  3. 勾選【Task】以形成待辦事項格式
  4. 勾選【Insert after】,指定要插入內容到那個段落
    1. 輸入標題文字
    2. 勾選【Insert at end of section】
  5. 變更【Create line if not found】為【Bottom】
  6. 勾選【Capture format】並輸入腳本碼(全形倒引號要改成半形):
‘‘‘js quickadd
let text = await this.quickAddApi.utility.getClipboard();
text = await this.quickAddApi.inputPrompt("添加靈感筆記", "輸入內容", text);
text = text.replace("\n", "<br>");

return text;
‘‘‘
<% tp.file.cursor(1) %>
title: 缺點
方法1與方法2者都必須在Obsidian裡操作,但有可能靈感來時正好在使用別的應用程式。

方法3. 由外部應用直接新增

不必在Obsidian裡,直接執行AutoHotkey的彈出式視窗,輸入內容後透過Advanced Obsidian URI將內容插入每日筆記的指定標題處。

;; fleeting-note.ahk
;; Input any ideas into Obsidian's Daily note.
;; Hotkey: Alt+D
;; Author: emisjerry, http://jdev.tw/blog/
#SingleInstance Force

global valut := "MOC"
global note := "020-Daily/" . A_YYYY . "-" . A_MM . "-" . A_DD . "_" . A_DDD
global heading := "靈光一閃"

!d::
  text = %Clipboard%
  text := MultiLineInputBox("Your ideas: ", text, "Insert your ideas into Daily note")
  if (text != "") {
    text := StrReplace(text, "`n", "<br>")
    text := StrReplace(text, "`r", "")
    text := encodeURI("- [ ] " . text)  ;; encodes and changes to a todo item
    text := StrReplace(text, "`n", "<br>")
    text := StrReplace(text, "`r", "")
    ;;msgbox text=%text%$
    Run obsidian://advanced-uri?vault=%valut%&filepath=%note%&heading=%heading%&data=%text%&mode=append
  }

  return

MultiLineInputBox(Text:="", Default:="", Caption:="Multi Line Input Box"){
  static
  ButtonOK:=ButtonCancel:= false
  if !MultiLineInputBoxGui{
    Gui, MultiLineInputBox: Font, s14, Segoe UI
    Gui, MultiLineInputBox: add, Text, r1 w600  , % Text
    Gui, MultiLineInputBox: add, Edit, r10 w600 vMultiLineInputBox, % Default
    Gui, MultiLineInputBox: add, Button, w100 h50 x380 gMultiLineInputBoxOK , &OK
    Gui, MultiLineInputBox: add, Button, w100 h50 x+10 gMultiLineInputBoxCancel, &Cancel
    MultiLineInputBoxGui := true
  }
  GuiControl,MultiLineInputBox:, MultiLineInputBox, % Default
  Gui, MultiLineInputBox: Show,, % Caption
  SendMessage, 0xB1, 0, -1, Edit1, A
  while !(ButtonOK||ButtonCancel)
    continue
  if ButtonCancel
    return
  Gui, MultiLineInputBox: Submit, NoHide
  Gui, MultiLineInputBox: Cancel
  return MultiLineInputBox
  ;----------------------
  MultiLineInputBoxOK:
  ButtonOK:= true
  return
  ;---------------------- 
  MultiLineInputBoxGuiEscape:
  MultiLineInputBoxCancel:
  ButtonCancel:= true
  Gui, MultiLineInputBox: Cancel
  return
}

encodeURI(Uri, Enc = "UTF-8")
{
  StrPutVar(Uri, Var, Enc)
  f := A_FormatInteger
  SetFormat, IntegerFast, H
  Loop
  {
  Code := NumGet(Var, A_Index - 1, "UChar")
  If (!Code)
    Break
  If (Code >= 0x30 && Code <= 0x39 ; 0-9
    || Code >= 0x41 && Code <= 0x5A ; A-Z
    || Code >= 0x61 && Code <= 0x7A) ; a-z
    Res .= Chr(Code)
  Else
    Res .= "%" . SubStr(Code + 0x100, -1)
  }
  SetFormat, IntegerFast, %f%
  Return, Res
}

decodeURI(Uri, Enc = "UTF-8")
{
  Pos := 1
  Loop
  {
  Pos := RegExMatch(Uri, "i)(?:%[\da-f]{2})+", Code, Pos++)
  If (Pos = 0)
    Break
  VarSetCapacity(Var, StrLen(Code) // 3, 0)
  StringTrimLeft, Code, Code, 1
  Loop, Parse, Code, `%
    NumPut("0x" . A_LoopField, Var, A_Index - 1, "UChar")
  StringReplace, Uri, Uri, `%%Code%, % StrGet(&Var, Enc), All
  }
  Return, Uri
}

StrPutVar(Str, ByRef Var, Enc = "")
{
  Len := StrPut(Str, Enc) * (Enc = "UTF-16" || Enc = "CP1200" ? 2 : 1)
  VarSetCapacity(Var, Len, 0)
  Return, StrPut(Str, &Var, Enc)
}

相關連結

  • temlater-fleeting-note.md: https://gist.github.com/emisjerry/8939f9aa8f4de9eab377b1461cb4f9bd
  • fleeting-note.ahk: https://gist.github.com/emisjerry/01ec842be695a5248db642206b96dee7

教學影片

##

您可能也會有興趣的類似文章

簡睿

服務於軟體業的資訊老兵。興趣廣泛,學習力佳,樂於分享所知所學。

您可能也會喜歡…

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *