zsh: functions: add mangrep

fix-ci
bretello 2023-01-23 20:21:57 +01:00
parent 3b6cf2b92f
commit a8c89d32c9
Signed by: brethil
GPG Key ID: 876AAC6290170FE7
1 changed files with 18 additions and 0 deletions

View File

@ -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 <pattern> <command>"
echo "Opens man page for <command> at the first match for <pattern>"
return
fi
pattern=$1
cmd=$2
if [[ -z "$cmd" ]]; then
man "$cmd"
return
fi
MANPAGER="less -p \"$pattern\"" man "$cmd"
}