summaryrefslogtreecommitdiff
path: root/plugins/z/_z
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2022-11-05 14:55:11 -0700
committerTuowen Zhao <ztuowen@gmail.com>2022-11-05 14:55:11 -0700
commit04b8c052e5b624873b352889423c753ed1baf9c4 (patch)
tree78e14fe69e61d69709f31f91b7ae29fe8bc74477 /plugins/z/_z
parent1a6dcd017dbf564058a729032de3db139fcf9c7e (diff)
parent80fdbc9b91a9acca42fb90065b5e64a9722978a7 (diff)
downloadzsh-04b8c052e5b624873b352889423c753ed1baf9c4.tar.gz
zsh-04b8c052e5b624873b352889423c753ed1baf9c4.tar.bz2
zsh-04b8c052e5b624873b352889423c753ed1baf9c4.zip
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'plugins/z/_z')
-rw-r--r--plugins/z/_z82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/z/_z b/plugins/z/_z
new file mode 100644
index 000000000..9891a52ed
--- /dev/null
+++ b/plugins/z/_z
@@ -0,0 +1,82 @@
+#compdef zshz ${ZSHZ_CMD:-${_Z_CMD:-z}}
+#
+# Zsh-z - jump around with Zsh - A native Zsh version of z without awk, sort,
+# date, or sed
+#
+# https://github.com/agkozak/zsh-z
+#
+# Copyright (c) 2018-2022 Alexandros Kozak
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+# z (https://github.com/rupa/z) is copyright (c) 2009 rupa deadwyler and
+# licensed under the WTFPL license, Version 2.a
+#
+# shellcheck shell=ksh
+
+############################################################
+# Zsh-z COMPLETIONS
+############################################################
+emulate -L zsh
+(( ZSHZ_DEBUG )) &&
+ setopt LOCAL_OPTIONS WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
+
+# TODO: This routine currently reproduces z's feature of allowing spaces to be
+# used as wildcards in completions, so that
+#
+# z us lo bi
+#
+# can expand to
+#
+# z /usr/local/bin
+#
+# but it also reproduces z's buggy display on the commandline, viz.
+#
+# z us lo /usr/local/bin
+#
+# Address.
+
+local completions expl completion
+local -a completion_list
+
+completions=$(zshz --complete ${(@)words:1})
+[[ -z $completions ]] && return 1
+
+for completion in ${(f)completions[@]}; do
+ if (( ZSHZ_TILDE )) && [[ $completion == ${HOME}* ]]; then
+ completion="~${(q)${completion#${HOME}}}"
+ else
+ completion="${(q)completion}"
+ fi
+ completion_list+=( $completion )
+done
+
+_description -V completion_list expl 'directories'
+
+if [[ $ZSHZ_COMPLETION == 'legacy' ]]; then
+ compadd "${expl[@]}" -QU -- "${completion_list[@]}"
+else
+ compadd "${expl[@]}" -QU -V zsh-z -- "${completion_list[@]}"
+fi
+
+compstate[insert]=menu
+
+return 0
+
+# vim: ft=zsh:fdm=indent:ts=2:et:sts=2:sw=2: