Skip to content

Instantly share code, notes, and snippets.

@boneskull
Created June 3, 2025 22:40
Show Gist options
  • Save boneskull/9c1944eab0d3a3d0d476f2e783507390 to your computer and use it in GitHub Desktop.
Save boneskull/9c1944eab0d3a3d0d476f2e783507390 to your computer and use it in GitHub Desktop.
oh-my-zsh: open manpages in Dash.app (macOS Sequoia)

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}"
}
[[ -n $(mdfind "kMDItemFSName == 'Dash.app'" | head -n1) && -d "$HOME/Library/Application Support/Dash/DocSets/Man_Pages" ]] && {
dash_man() {
/usr/bin/open "dash://?query=manpages:$(omz_urlencode ${@})"
}
alias man=dash_man
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment