4 # zaw source for xdg-open to open file
7 function zaw-src-open-file
() {
9 setopt local_options null_glob
11 if (( $# == 0 )); then
18 if [[ "${parent}" != */ ]]; then
21 candidates
+=("${parent}")
22 cand_descriptions
+=("../")
24 # TODO: symlink to directory
25 for d
in "${root%/}"/*(/); do
27 cand_descriptions
+=("${d:t}/")
30 for f
in "${root%/}"/*(^
/); do
32 cand_descriptions
+=("${f:t}")
35 actions
=( "zaw-callback-open-file" "zaw-callback-append-to-buffer" )
36 act_descriptions
=( "open file or directory" "append to edit buffer" )
37 # TODO: open multiple files
39 options
=( "-t" "${root}" )
42 zaw-register-src
-n open-file zaw-src-open-file
44 function zaw-callback-open-file
() {
46 case "${(L)OSTYPE}" in
54 # TODO: what is the best fallback?
59 # TODO: symlink to directory
60 if [[ -d "$1" ]]; then
61 zaw zaw-src-open-file
"$1"
63 BUFFER
="${open} ${(q)1}"