make fnhelp more usable
This commit is contained in:
parent
9109619f2f
commit
f264a64950
1 changed files with 9 additions and 4 deletions
|
@ -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-
|
||||||
|
|
Loading…
Reference in a new issue