]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/z/_z
initial
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / z / _z
1 #compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
2 #
3 # Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort,
4 # date, or sed
5 #
6 # https://github.com/agkozak/zsh-z
7 #
8 # Copyright (c) 2018-2022 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 # z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and
29 # licensed under the WTFPL license, Version 2.a
30 #
31 # shellcheck shell=ksh
32
33 ############################################################
34 # Zsh-z COMPLETIONS
35 ############################################################
36 emulate -L zsh
37 (( ZSHZ_DEBUG )) &&
38   setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
39
40 # TODO: This routine currently reproduces z's feature of allowing spaces to be
41 # used as wildcards in completions, so that
42 #
43 #   z us lo bi
44 #
45 # can expand to
46 #
47 #   z /usr/local/bin
48 #
49 # but it also reproduces z's buggy display on the commandline, viz.
50 #
51 #   z us lo /usr/local/bin
52 #
53 # Address.
54
55 local completions expl completion
56 local -a completion_list
57
58 completions=$(zshz --complete ${(@)words:1})
59 [[ -z $completions ]] && return 1
60
61 for completion in ${(f)completions[@]}; do
62   if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then
63     completion="~${(q)${completion#${HOME}}}"
64   else
65     completion="${(q)completion}"
66   fi
67   completion_list+=( $completion )
68 done
69
70 _description -V completion_list expl 'directories'
71
72 if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then
73   compadd "${expl[@]}" -QU -- "${completion_list[@]}"
74 else
75   compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}"
76 fi
77
78 compstate[insert]=menu
79
80 return 0
81
82 # vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2: