1 #compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
3 # Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort,
6 # https://github.com/agkozak/zsh-z
8 # Copyright (c) 2018-2022 Alexandros Kozak
10 # Permission is hereby granted, free of charge, to any person obtaining a copy
11 # of this software and associated documentation files (the "Software"), to deal
12 # in the Software without restriction, including without limitation the rights
13 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 # copies of the Software, and to permit persons to whom the Software is
15 # furnished to do so, subject to the following conditions:
17 # The above copyright notice and this permission notice shall be included in all
18 # copies or substantial portions of the Software.
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 # z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and
29 # licensed under the WTFPL license, Version 2.a
31 # shellcheck shell=ksh
33 ############################################################
35 ############################################################
38 setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
40 # TODO: This routine currently reproduces z's feature of allowing spaces to be
41 # used as wildcards in completions, so that
49 # but it also reproduces z's buggy display on the commandline, viz.
51 # z us lo /usr/local/bin
55 local completions expl completion
56 local -a completion_list
58 completions=$(zshz --complete ${(@)words:1})
59 [[ -z $completions ]] && return 1
61 for completion in ${(f)completions[@]}; do
62 if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then
63 completion="~${(q)${completion#${HOME}}}"
65 completion="${(q)completion}"
67 completion_list+=( $completion )
70 _description -V completion_list expl 'directories'
72 if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then
73 compadd "${expl[@]}" -QU -- "${completion_list[@]}"
75 compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}"
78 compstate[insert]=menu
82 # vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2: