diff --git a/book.org b/book.org index d6739e7..368d101 100644 --- a/book.org +++ b/book.org @@ -1196,6 +1196,23 @@ } #+end_src + Well... after implementing this, I discovered `select`, which allows for these kinds of flows: + + #+begin_src bash + mute command -v fzf || + fzf() { + local in=$(cat) + for p in "${@}"; do + [ "$p" = "-0" ] && [ "$(echo "$in" | wc -l)" -eq 1 ] && [ "" = "$in" ] && return 1 + [ "$p" = "-1" ] && [ "$(echo "$in" | wc -l)" -eq 1 ] && [ "" != "$in" ] && echo "$in" && return + done + select opt in $(echo "$in"); do + [ -n "$opt" ] && break + done >/dev/tty