make fnhelp more usable

This commit is contained in:
Daylin Morgan 2023-11-09 15:58:37 -06:00
parent 9109619f2f
commit f264a64950
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F

View file

@ -1,13 +1,18 @@
#!/usr/bin/env zsh
##? fnhelp - use '##?' comments in function files as help docs. ##? fnhelp - use '##?' comments in function files as help docs.
##? ##?
##? usage: fnhelp <func> ##? usage: fnhelp <func>
# function fnhelp {
local ZFUNCDIR="${ZFUNCDIR:-${ZDOTDIR:-~/.config/zsh}/functions}" local ZFUNCDIR="${ZFUNCDIR:-${ZDOTDIR:-~/.config/zsh}/functions}"
if [[ $# -eq 0 ]]; then
echo >&2 "no function specified"
fnhelp fnhelp
return 1
fi
if [[ ! -f "$ZFUNCDIR/$1" ]]; then if [[ ! -f "$ZFUNCDIR/$1" ]]; then
echo >&2 "fnhelp: function not found '$1'." && return 1 echo >&2 "fnhelp: function not found '$1'." && return 1
fi fi
command grep "^##?" "$ZFUNCDIR/$1" | cut -c 5-
# }
# vim: ft=zsh sw=2 ts=2 et command grep "^##?" "$ZFUNCDIR/$1" | cut -c 5-