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:
parent
9a47fde0c8
commit
76164d6217
5 changed files with 18 additions and 8 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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}
|
||||||
|
|
|
@ -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})
|
||||||
|
|
|
@ -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
|
||||||
|
|
12
zimfw.zsh
12
zimfw.zsh
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue