Source

zaw-sources / zaw-myhtmldocs.zsh

Full commit
# -*- sh -*-
zmodload zsh/parameter

function zaw-src-myhtmldocs() {
    candidates=("${(ps:\n:)$(cd $ZAW_MYHTMLDOCS_DIR && find -L -name '*.html')}")
    actions=("zaw-callback-myhtmldocs-open")
    act_descriptions=("open myhtmldocs in browser")
}

zaw-register-src -n myhtmldocs zaw-src-myhtmldocs

export ZAW_MYHTMLDOCS_DIR="$HOME/repos/myhtmldocs/html"
export ZAW_MYHTMLDOCS_OPEN=browser
export ZAW_MYHTMLDOCS_PORT=8612

function zaw-callback-myhtmldocs-open() {
    local orig_buffer="${BUFFER}"
    local url="http://localhost:${ZAW_MYHTMLDOCS_PORT}/$1"
    BUFFER="${ZAW_MYHTMLDOCS_OPEN} '$url'"
    zle accept-line
}