diff --git a/functions/misc.zsh b/functions/misc.zsh index 34d68f3..426b34d 100755 --- a/functions/misc.zsh +++ b/functions/misc.zsh @@ -266,3 +266,21 @@ make_backup() { function find_by_mtime() { find $@ -printf "%T+ %p\n" | sort } + + +function mangrep() { + set -x + if [[ -z "$@" ]]; then + echo "Usage: $0 " + echo "Opens man page for at the first match for " + return + fi + pattern=$1 + cmd=$2 + if [[ -z "$cmd" ]]; then + man "$cmd" + return + fi + + MANPAGER="less -p \"$pattern\"" man "$cmd" +}