mirror of
https://github.com/zdharma-continuum/zinit-annex-bin-gem-node.git
synced 2026-09-10 07:26:18 -04:00
shim-list,plugin.zsh: Preliminary `shim-list' subcommand
This commit is contained in:
parent
2339f26634
commit
240629d5fe
|
|
@ -11,10 +11,16 @@ autoload .za-bgn-bin-or-src-function-body \
|
|||
.za-bgn-mod-function-body \
|
||||
→za-bgn-atload-handler →za-bgn-atclone-handler \
|
||||
→za-bgn-atpull-handler →za-bgn-help-handler \
|
||||
→za-bgn-atdelete-handler
|
||||
→za-bgn-atdelete-handler \
|
||||
→za-bgn-shim-list
|
||||
|
||||
# An empty stub to fill the help handler fields
|
||||
→za-bgn-help-null-handler() { :; }
|
||||
→za-bgn-null-handler() { :; }
|
||||
|
||||
@zinit-register-annex "z-a-bin-gem-node" \
|
||||
subcommand:shim-list \
|
||||
→za-bgn-shim-list \
|
||||
→za-bgn-null-handler
|
||||
|
||||
@zinit-register-annex "z-a-bin-gem-node" \
|
||||
hook:\!atload \
|
||||
|
|
@ -25,15 +31,15 @@ autoload .za-bgn-bin-or-src-function-body \
|
|||
@zinit-register-annex "z-a-bin-gem-node" \
|
||||
hook:atclone \
|
||||
→za-bgn-atclone-handler \
|
||||
→za-bgn-help-null-handler
|
||||
→za-bgn-null-handler
|
||||
|
||||
@zinit-register-annex "z-a-bin-gem-node" \
|
||||
hook:\%atpull \
|
||||
→za-bgn-atclone-handler \
|
||||
→za-bgn-help-null-handler
|
||||
→za-bgn-null-handler
|
||||
|
||||
@zinit-register-annex "z-a-bin-gem-node" \
|
||||
hook:atdelete \
|
||||
→za-bgn-atdelete-handler \
|
||||
→za-bgn-help-null-handler
|
||||
→za-bgn-null-handler
|
||||
|
||||
|
|
|
|||
47
→za-bgn-shim-list
Normal file
47
→za-bgn-shim-list
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# -*- mode: sh; sh-indentation: 4; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
# Copyright 2020 Sebastian Gniazdowski
|
||||
# License: MIT
|
||||
|
||||
# Synopsis:
|
||||
# zinit shim-list [-l|--local-dir] [-c|--cat] [-i|--from-ices]
|
||||
#
|
||||
|
||||
emulate -LR zsh
|
||||
setopt extended_glob warn_create_global typeset_silent \
|
||||
no_short_loops rc_quotes
|
||||
|
||||
autoload is-at-least
|
||||
local is_58
|
||||
is-at-least 5.8 && is_58=1
|
||||
|
||||
local -a opt_local_dir opt_cat opt_from_ices
|
||||
zparseopts -D -E ${is_58:+-F} \
|
||||
l=opt_local_dir -local-dir=opt_local_dir \
|
||||
c=opt_cat -cat=opt_cat \
|
||||
i=opt_from_ices -from-ices=opt_from_ices || \
|
||||
{
|
||||
print -Pr "$ZINIT[col-error]Error:$ZINIT[col-msg2]" \
|
||||
"Incorrect options given to" \
|
||||
"$ZINIT[col-obj]shim-list$ZINIT[col-msg2], try" \
|
||||
"$ZINIT[col-obj]--help%f"
|
||||
return 1
|
||||
}
|
||||
|
||||
local nl=$'\n' brace='{' quote='"'
|
||||
local pattern='(#s)\#!/usr/bin/env zsh
|
||||
|
||||
function * {
|
||||
local bindir="'
|
||||
local -a cands
|
||||
cands=( $ZPFX/bin/*(.-NDL-1000) )
|
||||
|
||||
local file
|
||||
for file ( $cands ) {
|
||||
local body="$(<$file)"
|
||||
if [[ -n ${body[(r)$pattern]} ]] {
|
||||
print -r -- $file:t
|
||||
}
|
||||
}
|
||||
|
||||
# vim:ft=zsh:sw=4:sts=4:noet:
|
||||
Loading…
Reference in a new issue