_z
2293 bytes
1#compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
2#
3# Zsh-z - jump around with Zsh - A native Zsh version of rupa/z without awk, sort,
4# date, or sed
5#
6# https://github.com/agkozak/zsh-z
7#
8# Copyright (c) 2018-2026 Alexandros Kozak
9#
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:
16#
17# The above copyright notice and this permission notice shall be included in all
18# copies or substantial portions of the Software.
19#
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
26# SOFTWARE.
27################################################################################
28
29############################################################
30# Zsh-z COMPLETIONS
31############################################################
32emulate -L zsh
33(( ZSHZ_DEBUG )) &&
34 setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
35
36local completions expl completion
37local -a completion_list
38
39completions=$(zshz --complete "${(@)words:1}")
40[[ -z $completions ]] && return 1
41
42for completion in ${(f)completions[@]}; do
43 if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then
44 completion="~${(q)${completion#${HOME}}}"
45 else
46 completion="${(q)completion}"
47 fi
48 completion_list+=( $completion )
49done
50
51_description -V completion_list expl 'directories'
52
53if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then
54 compadd "${expl[@]}" -QU -- "${completion_list[@]}"
55else
56 compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}"
57fi
58
59compstate[insert]=menu
60
61return 0
62
63# vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2: