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.

Revisions

  1. boneskull created this gist Jun 3, 2025.
    24 changes: 24 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    This is a snippet for `zsh` you can add to a `.zshrc` to automatically open manpages in [Dash](https://kapeli.com/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](https://ohmyz.sh).

    If you don't have `oh-my-zsh` installed, you can paste this into your `.zshrc` as a reasonable substitution:

    ```sh
    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}"
    }
    ```
    6 changes: 6 additions & 0 deletions dash_man.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    [[ -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
    }