This is a snippet for zsh
you can add to a .zshrc
to automatically open manpages in Dash if and only if the "Manpages" DocSet is installed. It's been tested with macOS Sequoia (v15.5).
It uses the omz_urlencode
function provided by oh-my-zsh.
If you don't have oh-my-zsh
installed, you can paste this into your .zshrc
as a reasonable substitution:
omz_urlencode() {
local string="${@}"
local strlen=${#string}
local encoded=""
for (( pos = 0; pos < strlen; pos ++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9]) o="${c}" ;;
*) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}