1
0
mirror of https://github.com/zplug/zplug synced 2025-08-30 01:30:43 +02:00
zplug/base/support/omz.zsh
Naoki Mizuno e01833c95e Change directory structure
lib/     -> base/
src/     -> misc/
src/ext/ -> base/sources/
2016-04-13 01:25:51 -04:00

52 lines
1.2 KiB
Bash

#!/bin/zsh
__zplug::support::omz::depends() {
local lib_f func_name dep
local -a target
local -a -U depends
local -a func_names
local -A omz_libs
local omz_repo="$ZPLUG_HOME/repos/$_ZPLUG_OHMYZSH"
for lib_f in "$omz_repo"/lib/*.zsh(.)
do
# List funcname in the library file
func_names=( ${(@f)"$( \
grep "^function" "$lib_f" \
| sed 's/^function *//g' \
| sed 's/() {$//g' \
| sed 's/ {$//g' \
| grep -v " " \
)"} )
# Make list that consists of the funcname and filename
for func_name in "${func_names[@]}"
do
omz_libs[$func_name]="$lib_f"
done
done
target=( "$omz_repo/${1:?}"{.zsh-theme,/*.plugin.zsh}(N-.) )
for lib_f in "${(k)omz_libs[@]}"
do
for t in "${target[@]}"
do
[[ -f $t ]] || continue
sed '/^ *#/d' "$t" \
| egrep "(^|\s|['\"(\`])$lib_f($|\s|[\\\\'\")\`])" \
&>/dev/null &&
depends+=( "$omz_libs[$lib_f]" )
done
done
# Return dependency list
for dep in "${depends[@]}"
do
echo "$dep"
done
}
__zplug::support::omz::theme() {
setopt prompt_subst
}