diff options
author | tdro <tdro@users.noreply.github.com> | 2021-03-08 17:06:53 -0500 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2021-03-08 17:06:53 -0500 |
commit | bc442f2a72051e965feb4be17181fdf3e6a3f167 (patch) | |
tree | ef8dababedb5701a085935929f600b41c274f061 /.local/bin/fzf-doc | |
parent | 5a338588e302156f0cab7ac442bdf335684b44af (diff) | |
download | dotfiles-bc442f2a72051e965feb4be17181fdf3e6a3f167.tar.gz dotfiles-bc442f2a72051e965feb4be17181fdf3e6a3f167.tar.bz2 dotfiles-bc442f2a72051e965feb4be17181fdf3e6a3f167.zip |
.local/bin/fzf-doc: Cache path
Read YAML files.
Diffstat (limited to '.local/bin/fzf-doc')
-rwxr-xr-x | .local/bin/fzf-doc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/.local/bin/fzf-doc b/.local/bin/fzf-doc index bf3b49e..6f51c08 100755 --- a/.local/bin/fzf-doc +++ b/.local/bin/fzf-doc @@ -1,5 +1,8 @@ #!/bin/sh -eu +cache=$HOME/.cache/fzf-doc +documentation=/etc/documentation + fzf_doc_preview() { file=$1 extension=${file##*.} @@ -11,14 +14,20 @@ fzf_doc_preview() { esac } -[ "${1-}" = "--preview" ] && fzf_doc_preview "${2-}" && exit; - -grep -lRi \ +if [ ! -f "$cache" ] || test "$cache" -ot "$documentation"; then + grep -lRi \ --include=*.md \ --include=*.txt \ --include=*.pdf \ --include=*.html \ - "${1-.}" /etc/documentation \ + --include=*.yml \ + --include=*.yaml \ + . /etc/documentation > "$cache"; +fi + +[ "${1-}" = "--preview" ] && fzf_doc_preview "${2-}" && exit; + +grep -i "${1-.}" "$cache" \ | fzf --preview "fzf-doc --preview {}" \ | while read -r file @@ -28,6 +37,8 @@ do md) mdcat -cl "$file" | vim - ;; html) w3m -dump "$file" | vim - ;; pdf) pdftotext "$file" - | vim - ;; + yml) vim "$file" ;; + yaml) vim "$file" ;; *) vim "$file" ;; esac done |