diff options
author | Carlo <carlosalag@protonmail.com> | 2022-10-18 19:10:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 19:10:55 +0200 |
commit | 7e3231b846dec87fcf6537f6e45c9c1be9f718fe (patch) | |
tree | 269d91adc4ff4c36b607e4d4c421fcc1bc1af26f /plugins/z/_z | |
parent | 818f3de1fa6588a94bf207766a811992e301acf1 (diff) | |
download | zsh-7e3231b846dec87fcf6537f6e45c9c1be9f718fe.tar.gz zsh-7e3231b846dec87fcf6537f6e45c9c1be9f718fe.tar.bz2 zsh-7e3231b846dec87fcf6537f6e45c9c1be9f718fe.zip |
feat(z): replace `rupa/z` with `agkozak/zsh-z` (#11236)
Diffstat (limited to 'plugins/z/_z')
-rw-r--r-- | plugins/z/_z | 82 |
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: |