diff options
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/fdoc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/.local/bin/fdoc b/.local/bin/fdoc index ab1b091..66d4594 100755 --- a/.local/bin/fdoc +++ b/.local/bin/fdoc @@ -1,18 +1,29 @@ #!/bin/sh -eu +fdoc_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" ] && fdoc_preview "${2-}" && exit; + grep -lRi \ --include=*.md \ --include=*.txt \ --include=*.html \ "${1-.}" /etc/documentation \ - | fzf --preview "grep -hi -B 10 -A 10 ${1-.} {}" \ + | fzf --preview "fdoc --preview {}" \ | while read -r doc do extension=${doc##*.} - case "$extension" in - md) vim "$doc" ;; + md) glow "$doc" | vim -;; html) w3m -dump "$doc" | vim - ;; *) vim "$doc" ;; esac |