antidote/functions/antidote-init

34 lines
751 B
Bash

#!/bin/zsh
### Initialize the shell for dynamic bundles.
#
# usage: antidote init [-h|--help]
# source <(antidote init)
#
# This function changes how the `antidote` command works by sourcing the results of
# `antidote bundle` instead of just generating the Zsh script.
#function antidote-init {
local o_help
zparseopts $_adote_zparopt_flags -- h=o_help -help=h || return 1
if (( $#o_help )); then
antidote-help init
return
fi
local script=(
'#!/usr/bin/env zsh'
'function antidote {'
' case "$1" in'
' bundle)'
' source <( antidote-main $@ ) || antidote-main $@'
' ;;'
' *)'
' antidote-main $@'
' ;;'
' esac'
'}'
)
printf "%s\n" "${script[@]}"
#}