1
0
Fork 0
mirror of synced 2024-11-30 03:05:35 -05:00

Allow zimfw.zsh to exist outside ZIM_HOME

and change initialization so ZIM_HOME is required before sourcing the
script.
This commit is contained in:
Eric Nielsen 2024-06-14 20:17:07 -05:00
parent 9a47fde0c8
commit 76164d6217
No known key found for this signature in database
GPG key ID: 678AF5E338C87D99
5 changed files with 18 additions and 8 deletions

View file

@ -10,7 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Don't allow calling `zmodule` from the command line. Let it fail with "command - Don't allow calling `zmodule` from the command line. Let it fail with "command
not found" instead. It's inteded to be used only in the .zimrc script. not found" instead, as it's intended to be used only in the .zimrc script.
- Allow zimfw.zsh to exist anywhere else, not only inside `ZIM_HOME`. This
enables installing the zimfw.zsh script independently with a package manager.
### Fixed ### Fixed

View file

@ -4,5 +4,9 @@ autoload -Uz is-at-least && if ! is-at-least <%= min_zsh_version %>; then
fi fi
autoload -Uz zargs autoload -Uz zargs
if (( ! ${+ZIM_HOME} )); then
print -u2 -R $'<%= red %>'${0}$': ZIM_HOME not defined<%= normal %>'
return 1
fi
# Define zimfw location # Define zimfw location
if (( ! ${+ZIM_HOME} )) typeset -g ZIM_HOME=${0:h} typeset -g __ZIMFW_PATH=${0:h}

View file

@ -5,7 +5,7 @@ _zimfw_build_init() {
command mv -f ${ztarget}{,.old} || return 1 command mv -f ${ztarget}{,.old} || return 1
fi fi
_zimfw_mv =( _zimfw_mv =(
print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" print -R "zimfw() { source ${(q-)__ZIMFW_PATH}/zimfw.zsh \"\${@}\" }"
local zroot_dir zpre local zroot_dir zpre
local -a zif_functions zif_cmds zroot_functions zroot_cmds local -a zif_functions zif_cmds zroot_functions zroot_cmds
local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds}) local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds})

View file

@ -1,5 +1,5 @@
_zimfw_upgrade() { _zimfw_upgrade() {
local -r ztarget=${ZIM_HOME}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz local -r ztarget=${__ZIMFW_PATH}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
{ {
if (( ${+commands[curl]} )); then if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1 command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1

View file

@ -30,8 +30,12 @@ autoload -Uz is-at-least && if ! is-at-least 5.2; then
fi fi
autoload -Uz zargs autoload -Uz zargs
if (( ! ${+ZIM_HOME} )); then
print -u2 -R $'\E[31m'${0}$': ZIM_HOME not defined\E[0m'
return 1
fi
# Define zimfw location # Define zimfw location
if (( ! ${+ZIM_HOME} )) typeset -g ZIM_HOME=${0:h} typeset -g __ZIMFW_PATH=${0:h}
_zimfw_print() { _zimfw_print() {
if (( _zprintlevel > 0 )) print "${@}" if (( _zprintlevel > 0 )) print "${@}"
@ -57,7 +61,7 @@ _zimfw_build_init() {
command mv -f ${ztarget}{,.old} || return 1 command mv -f ${ztarget}{,.old} || return 1
fi fi
_zimfw_mv =( _zimfw_mv =(
print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }" print -R "zimfw() { source ${(q-)__ZIMFW_PATH}/zimfw.zsh \"\${@}\" }"
local zroot_dir zpre local zroot_dir zpre
local -a zif_functions zif_cmds zroot_functions zroot_cmds local -a zif_functions zif_cmds zroot_functions zroot_cmds
local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds}) local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds})
@ -457,7 +461,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2024-06-03 13:45:11 UTC, previous commit is 96f60da)' print -R 'zimfw version: '${_zversion}' (built at 2024-06-15 01:16:55 UTC, previous commit is 9a47fde)'
local zparam local zparam
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
print -R ${(r.22....:.)zparam}${(P)zparam} print -R ${(r.22....:.)zparam}${(P)zparam}
@ -477,7 +481,7 @@ _zimfw_uninstall() {
} }
_zimfw_upgrade() { _zimfw_upgrade() {
local -r ztarget=${ZIM_HOME}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz local -r ztarget=${__ZIMFW_PATH}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
{ {
if (( ${+commands[curl]} )); then if (( ${+commands[curl]} )); then
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1 command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1