dotfiles/home/private_dot_config/zsh/functions/fnhelp

19 lines
414 B
Text
Raw Normal View History

2023-11-09 15:58:37 -06:00
#!/usr/bin/env zsh
2023-02-17 09:26:31 -06:00
##? fnhelp - use '##?' comments in function files as help docs.
##?
##? usage: fnhelp <func>
local ZFUNCDIR="${ZFUNCDIR:-${ZDOTDIR:-~/.config/zsh}/functions}"
2023-11-09 15:58:37 -06:00
if [[ $# -eq 0 ]]; then
echo >&2 "no function specified"
fnhelp fnhelp
return 1
fi
2023-02-17 09:26:31 -06:00
if [[ ! -f "$ZFUNCDIR/$1" ]]; then
echo >&2 "fnhelp: function not found '$1'." && return 1
fi
2023-11-09 15:58:37 -06:00
command grep "^##?" "$ZFUNCDIR/$1" | cut -c 5-