diff options
Diffstat (limited to '.local/bin/fzf-doc')
-rwxr-xr-x | .local/bin/fzf-doc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.local/bin/fzf-doc b/.local/bin/fzf-doc new file mode 100755 index 0000000..f30f23e --- /dev/null +++ b/.local/bin/fzf-doc @@ -0,0 +1,30 @@ +#!/bin/sh -eu + +fzf_doc_preview() { + file=$1 + extension=${file##*.} + case "$extension" in + md) glow -w 60 "$file" ;; + html) w3m -dump "$file" ;; + *) grep -hi -B 10 -A 10 . "${file}" ;; + esac +} + +[ "${1-}" = "--preview" ] && fzf_doc_preview "${2-}" && exit; + +grep -lRi \ + --include=*.md \ + --include=*.txt \ + --include=*.html \ + "${1-.}" /etc/documentation \ + | fzf --preview "fzf-doc --preview {}" \ + | while read -r doc + +do + extension=${doc##*.} + case "$extension" in + md) glow "$doc" | vim -;; + html) w3m -dump "$doc" | vim - ;; + *) vim "$doc" ;; + esac +done |