Skip to content

Instantly share code, notes, and snippets.

@henices
Created January 7, 2026 01:10
Show Gist options
  • Select an option

  • Save henices/795b9a7ebdbe5de9ea822ccf23156a32 to your computer and use it in GitHub Desktop.

Select an option

Save henices/795b9a7ebdbe5de9ea822ccf23156a32 to your computer and use it in GitHub Desktop.
logseq block search
lg() {
# 1. 第一步搜索:
# --heading: 文件名单独显示在第一行(关键修改!)
# --line-number: 显示行号,方便你跳转(可选)
# --color never: 纯文本输出,交给下一步上色
rg -g '!*Desktop.md' -U -P -t md --heading --line-number --color never \
'(?s)^- (?:(?!^- ).)*?'"$1"'(?:(?!^- ).)*' \
| \
# 2. 第二步高亮:
# 透传所有文本,只给关键字上色(黑字黄底,超显眼)
rg --passthrough --color always --colors 'match:bg:yellow' --colors 'match:fg:black' -F "$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment