From f264a64950553708387c11545313cc85942db211 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 9 Nov 2023 15:58:37 -0600 Subject: [PATCH] make fnhelp more usable --- home/private_dot_config/zsh/functions/fnhelp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/home/private_dot_config/zsh/functions/fnhelp b/home/private_dot_config/zsh/functions/fnhelp index 5a2c7d6..e3958a1 100644 --- a/home/private_dot_config/zsh/functions/fnhelp +++ b/home/private_dot_config/zsh/functions/fnhelp @@ -1,13 +1,18 @@ +#!/usr/bin/env zsh ##? fnhelp - use '##?' comments in function files as help docs. ##? ##? usage: fnhelp -# function fnhelp { 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- -# } -# vim: ft=zsh sw=2 ts=2 et +command grep "^##?" "$ZFUNCDIR/$1" | cut -c 5-