xxh/xxh_xxh/xxh.zsh

40 lines
1.1 KiB
Bash
Raw Normal View History

2020-03-13 14:44:01 +00:00
#
# This entrypoint is to allow xxh getting current environment variables
# and pass some of them to xxh session to seamless transition to host.
#
# Usage in zsh: source xxh.zsh [ordinary xxh arguments]
#
2020-03-13 20:51:30 +00:00
local_xxh_home=~/.xxh
eargs=""
2020-03-14 11:36:46 +00:00
setopt +o nomatch
2020-03-28 08:25:16 +00:00
for pluginenv_file in $local_xxh_home/.xxh/plugins/*-zsh-*/env; do
2020-03-13 20:51:30 +00:00
if [[ -f $pluginenv_file ]]; then
plugin_name=$(basename `dirname $pluginenv_file` | tr a-z A-Z | sed 's/-/_/g')
if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then
echo Load plugin env $pluginenv_file
fi
for l in `cat $pluginenv_file`
do
2020-03-14 15:06:09 +00:00
if [[ -v $l ]]; then
d=`declare -p $l | base64 --wrap=0`
dd="export $plugin_name"_EXE_"$l=$d"
ddd=`echo $dd | base64 --wrap=0`
if [[ $XXH_VERBOSE == '2' ]]; then
echo Prepare plugin env $pluginenv_file: name=$l, declare=$d
echo Prepare plugin env $pluginenv_file bash: $dd
fi
eargs="$eargs +heb $ddd"
2020-03-13 20:51:30 +00:00
fi
done
fi
done
2020-03-14 11:36:46 +00:00
setopt -o nomatch
2020-03-13 20:51:30 +00:00
2020-03-22 09:26:10 +00:00
CDIR="$(cd "$(dirname "$0")" && pwd)"
[ -f $CDIR/xxh ] && xxh=$CDIR/xxh || xxh='xxh'
2020-03-21 21:27:59 +00:00
$xxh "$@" +s xxh-shell-zsh ${(z)eargs}