38 lines
1.1 KiB
Bash
38 lines
1.1 KiB
Bash
#!/bin/zsh
|
|
|
|
### Generate background clone commands
|
|
#function __antidote_bulk_clone {
|
|
emulate -L zsh; setopt local_options $_adote_funcopts
|
|
|
|
# Allow the user to define zsh-defer repo in case they want to fork it.
|
|
local zsh_defer_bundle
|
|
zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \
|
|
|| zsh_defer_bundle='romkatv/zsh-defer'
|
|
|
|
# get a list of clonable repos from a bundle file
|
|
$__adote_awkcmd -v ZSH_DEFER_BUNDLE=$zsh_defer_bundle '
|
|
BEGIN { RS="[\r\n]" }
|
|
|
|
# initialize vars
|
|
{ bundle=""; opts="--kind clone" }
|
|
|
|
# skip blank or commented lines
|
|
/^ *(#.+)?$/ { next }
|
|
|
|
# clone zsh-defer
|
|
/kind:defer/ { print "antidote-script --kind clone " ZSH_DEFER_BUNDLE " &" }
|
|
|
|
# handle user/repo and URL forms
|
|
$1~/^[^\/]+\/[^\/]+$/ { bundle=$1 }
|
|
$1~/^(https?:|(ssh|git)@)/ { bundle=$1 }
|
|
|
|
# find branch annotation if it exists
|
|
match($0, /branch:[^\t ]+/) { opts=opts " --branch " substr($0, RSTART+7, RLENGTH-7) }
|
|
|
|
# print result
|
|
bundle!=""{ print "antidote-script", opts, bundle, "&" }
|
|
|
|
END { print "wait" }
|
|
|
|
' "$@" | sort | uniq
|
|
#}
|