Last active
October 3, 2020 11:13
-
-
Save e-roux/e85f7d44fc3d9bbd453157da2e24fa55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
hooks=(chpwd periodic precmd preexec zshaddhistory zshexit) | |
for hook in $hooks; do | |
# First eval the hook function, stored as string | |
eval "hook_func_str=$\"${hook}_functions\"" | |
# [expansion rule](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Rules) | |
# [Parameter expansion flags](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags) | |
eval "hookfunc=\"${hook_func_str}\"" | |
# Make an array out of the string | |
hookfunc=( ${(s/ /)${hookfunc}} ) | |
# print ${(t)hookfunc}, $#hookfunc, $hookfunc[1] | |
# Print only the non empty arrays | |
if [ $#hookfunc != 0 ]; then | |
echo $hook | |
for fun in $=hookfunc; do | |
print "| $fun" | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment