Skip to content

Commit

Permalink
Fix minimal install (tarjoilija#90)
Browse files Browse the repository at this point in the history
- Create the directory of `init.zsh` if it does not exist
- Do not blindly expand ZGEN_{PREZTO_OPTIONS,COMPLETIONS,LOADED}

Closes tarjoilija#89
  • Loading branch information
jandamm authored Nov 18, 2021
1 parent 028367a commit ecd6af3
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions functions/zgenom-save
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ function __zgenom_write() {
function zgenom-save() {
__zgenom_err 'Creating `'"${ZGEN_INIT}"'` ...'

# Make sure the folder where ZGEN_INIT is stored exists
local init_dir=${ZGEN_INIT:h}
[[ -d $init_dir ]] || mkdir -p $init_dir

__zgenom_out "# {{{" >! "${ZGEN_INIT}"
__zgenom_write "# Generated by zgenom."
__zgenom_write "# This file will be overwritten the next time you run zgenom save!"
Expand Down Expand Up @@ -50,7 +54,7 @@ function zgenom-save() {
__zgenom_write
__zgenom_write "ZSH=$ZSH"
fi
if [[ ${ZGEN_USE_PREZTO} == 1 ]]; then
if [[ ${ZGEN_USE_PREZTO} == 1 && $#ZGEN_PREZTO_OPTIONS -gt 0 ]]; then
__zgenom_write
__zgenom_write "# ### Prezto initialization"
for option in "${ZGEN_PREZTO_OPTIONS[@]}"; do
Expand All @@ -61,19 +65,23 @@ function zgenom-save() {
# Set up fpath, load completions
# NOTE: This *intentionally* doesn't use ${ZGEN_COMPINIT_FLAGS}; the only
# available flags are meaningless in the presence of `-C`.
__zgenom_write
__zgenom_write "# ### Plugins & Completions"
__zgenom_write 'fpath=('"${(@qOa)ZGEN_COMPLETIONS}"' ${fpath})'
if [[ $#ZGEN_COMPLETIONS -gt 0 ]]; then
__zgenom_write
__zgenom_write "# ### Plugins & Completions"
__zgenom_write 'fpath=('"${(@qOa)ZGEN_COMPLETIONS}"' ${fpath})'
fi

local file
__zgenom_write
__zgenom_write "# ### General modules"
__zgenom_write "typeset -ga zsh_loaded_plugins"
for i in {1.."${#ZGEN_LOADED}"}; do
file="${ZGEN_LOADED[$i]}"
__zgenom_write "zsh_loaded_plugins+=( ${(qqq)ZGENOM_LOADED[$i]} )"
__zgenom_write "ZERO=${(qqq)file} source ${(qqq)file}"
done
if [[ $#ZGEN_LOADED -gt 0 ]]; then
local i file
__zgenom_write
__zgenom_write "# ### General modules"
__zgenom_write "typeset -ga zsh_loaded_plugins"
for i in {1.."${#ZGEN_LOADED}"}; do
file="${ZGEN_LOADED[$i]}"
__zgenom_write "zsh_loaded_plugins+=( ${(qqq)ZGENOM_LOADED[$i]} )"
__zgenom_write "ZERO=${(qqq)file} source ${(qqq)file}"
done
fi

if [[ ${ZGEN_AUTOLOAD_COMPINIT} == 1 ]]; then
__zgenom_write
Expand Down

0 comments on commit ecd6af3

Please sign in to comment.