From 39c5787e53dcd1302e31f45495d8a698bbd1c2ef Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 8 Aug 2020 22:06:06 -0400 Subject: .local/bin/fzf: Namespacing --- .local/bin/fdoc | 30 ------------------------------ .local/bin/fman | 9 --------- .local/bin/fmark | 9 --------- .local/bin/fzf-doc | 30 ++++++++++++++++++++++++++++++ .local/bin/fzf-file | 2 ++ .local/bin/fzf-file-mark | 9 +++++++++ .local/bin/fzf-man | 9 +++++++++ 7 files changed, 50 insertions(+), 48 deletions(-) delete mode 100755 .local/bin/fdoc delete mode 100755 .local/bin/fman delete mode 100755 .local/bin/fmark create mode 100755 .local/bin/fzf-doc create mode 100755 .local/bin/fzf-file create mode 100755 .local/bin/fzf-file-mark create mode 100755 .local/bin/fzf-man (limited to '.local') diff --git a/.local/bin/fdoc b/.local/bin/fdoc deleted file mode 100755 index 66d4594..0000000 --- a/.local/bin/fdoc +++ /dev/null @@ -1,30 +0,0 @@ -#!/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 "fdoc --preview {}" \ - | while read -r doc - -do - extension=${doc##*.} - case "$extension" in - md) glow "$doc" | vim -;; - html) w3m -dump "$doc" | vim - ;; - *) vim "$doc" ;; - esac -done diff --git a/.local/bin/fman b/.local/bin/fman deleted file mode 100755 index 0d7e7ba..0000000 --- a/.local/bin/fman +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -eu - -MANWIDTH=9999 - -[ "$#" = 0 ] && apropos . \ - | cut -d' ' -f1 | fzf --preview "MANWIDTH=$MANWIDTH man {}" | xargs man; - -[ "$#" = 1 ] && man -k "$1" \ - | cut -d' ' -f1 | fzf --preview "MANWIDTH=$MANWIDTH man {}" | xargs man; diff --git a/.local/bin/fmark b/.local/bin/fmark deleted file mode 100755 index 8a306c6..0000000 --- a/.local/bin/fmark +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -file=$HOME/Documents/.fzf-fmarks -temp=/tmp/.fzf-fmarks.tmp - -realpath "$1" && realpath "$1" >> "$file"; -sed -i "s|$HOME|~|g" "$file"; - -awk '!visited[$0]++' "$file" > "$temp"; -mv -f "$temp" "$file"; 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 diff --git a/.local/bin/fzf-file b/.local/bin/fzf-file new file mode 100755 index 0000000..8580595 --- /dev/null +++ b/.local/bin/fzf-file @@ -0,0 +1,2 @@ +#!/bin/sh -eu +fzf < "$FZF_FILE_MARKS" | xargs -I{} sh -c "vim {}"; diff --git a/.local/bin/fzf-file-mark b/.local/bin/fzf-file-mark new file mode 100755 index 0000000..8a306c6 --- /dev/null +++ b/.local/bin/fzf-file-mark @@ -0,0 +1,9 @@ +#!/bin/sh +file=$HOME/Documents/.fzf-fmarks +temp=/tmp/.fzf-fmarks.tmp + +realpath "$1" && realpath "$1" >> "$file"; +sed -i "s|$HOME|~|g" "$file"; + +awk '!visited[$0]++' "$file" > "$temp"; +mv -f "$temp" "$file"; diff --git a/.local/bin/fzf-man b/.local/bin/fzf-man new file mode 100755 index 0000000..0d7e7ba --- /dev/null +++ b/.local/bin/fzf-man @@ -0,0 +1,9 @@ +#!/bin/sh -eu + +MANWIDTH=9999 + +[ "$#" = 0 ] && apropos . \ + | cut -d' ' -f1 | fzf --preview "MANWIDTH=$MANWIDTH man {}" | xargs man; + +[ "$#" = 1 ] && man -k "$1" \ + | cut -d' ' -f1 | fzf --preview "MANWIDTH=$MANWIDTH man {}" | xargs man; -- cgit v1.2.3