dotfiles/home/private_dot_config/zsh/functions/executable_fnhelp

18 lines
414 B
Bash

#!/usr/bin/env zsh
##? fnhelp - use '##?' comments in function files as help docs.
##?
##? usage: fnhelp <func>
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
echo >&2 "fnhelp: function not found '$1'." && return 1
fi
command grep "^##?" "$ZFUNCDIR/$1" | cut -c 5-