Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.81 KB

ListBacklinks.md

File metadata and controls

55 lines (40 loc) · 1.81 KB

List Backlinks

Requirements

  • xclip
  • ripgrep
  • sd (sed Alternative)
  • Notes should ideally have unique and descriptive names like a Zettelkasten
    • Directories are fine
    • There's no need for UUID's, descriptive file names are much easier.

How To

Put the following in your bash Make a bash script, an alias or a function in ~/.bashrc/~/.zshrc/~/.config/fish/config.fish for the following piece of bash:

function BackLinks() {
## If your using fish
  ## set term "$(xclip -selection clipboard -o | xargs basename |  cut -f 1 -d '.')"

## If your using bash/zsh
    term=$(xclip -selection clipboard -o | xargs basename |  cut -f 1 -d '.')
    
## The Grep
    rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
        ~/Notes/  -t markdown -ol
        
## If you want to preview the Backlinks
 ##  rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
 ##      ~/Notes/  -t markdown -ol \
 ##  fzf --bind pgup:preview-page-up,pgdn:preview-page-down --preview "mdcat {}"
}

alias bl='BackLinks'

Usage

  1. Make some .md files in ~/Notes that are interlinked with [[wiki-links]] and [markdown](./links.md)
  2. Copy the note path to the clipboard
  3. Run the command from above
  4. Anything that contains links to the current note should be returned.

Building on it

You can get creative and turn these into wiki-links as well.

 bl | sed s/^/basename\ / | bash | cut -f 1 -d '.' | sed s/^/\[\[/ | sed s/\$/\]\]/