1
0
Fork 0
mirror of synced 2024-12-25 07:23:21 -05:00

Allow customizing .zimrc file path

with the ZIM_CONFIG_FILE environment variable.
Fixes #479.
This commit is contained in:
Eric Nielsen 2022-10-23 19:34:14 -05:00
parent 3959a7f4e0
commit e54958b91c
No known key found for this signature in database
GPG key ID: 678AF5E338C87D99
6 changed files with 17 additions and 15 deletions

View file

@ -1,7 +1,7 @@
_zimfw_build_init() {
local -r ztarget=${ZIM_HOME}/init.zsh
# Force update of init.zsh if it's older than .zimrc
if [[ ${ztarget} -ot <%= home %>/.zimrc ]]; then
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} ]]; then
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(

View file

@ -1,7 +1,7 @@
_zimfw_build_login_init() {
local -r ztarget=${ZIM_HOME}/login_init.zsh
# Force update of login_init.zsh if it's older than .zimrc
if [[ ${ztarget} -ot <%= home %>/.zimrc ]]; then
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} ]]; then
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(

View file

@ -1,7 +1,8 @@
zmodule() {
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}
local -r zusage="Usage: %B${0}%b <url> [%B-n%b|%B--name%b <module_name>] [%B-r%b|%B--root%b <path>] [options]
Add %Bzmodule%b calls to your %B${ZDOTDIR:-${HOME}}/.zimrc%b file to define the modules to be initialized.
Add %Bzmodule%b calls to your %B${ztarget}%b file to define the modules to be initialized.
The initialization will be done in the same order it's defined.
<url> Module absolute path or repository URL. The following URL formats
@ -60,8 +61,8 @@ Per-call initialization options:
other per-call initialization options, so only your provided values will be used. I.e. these
values are either all automatic, or all manual in each zmodule call. To use default values
and also provided values, use separate zmodule calls."
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
print -u2 -PlR "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f" '' ${zusage}
if [[ ${${funcfiletrace[1]%:*}:A} != ${ztarget:A} ]]; then
print -u2 -PlR "%F{red}${0}: Must be called from %B${ztarget}%b%f" '' ${zusage}
return 2
fi
if (( ! # )); then

View file

@ -1,5 +1,5 @@
_zimfw_source_zimrc() {
local -r ztarget=<%= home %>/.zimrc _zflags=${1}
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1}
local -i _zfailed=0
if ! source ${ztarget} || (( _zfailed )); then
print -u2 -PR "%F{red}<%= failed %>Failed to source %B${ztarget}%b%f"

View file

@ -12,7 +12,7 @@ Actions:
%Bcompile%b Compile Zsh files.
%Bhelp%b Print this help.
%Binfo%b Print Zim and system info.
%Blist%b List all modules currently defined in %B<%= home %>/.zimrc%b.
%Blist%b List all modules currently defined in %B${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}%b.
Use %B-v%b to also see the modules details.
%Binit%b Same as %Binstall%b, but with output tailored to be used at terminal startup.
%Binstall%b Install new modules. Also does %Bbuild%b, %Bcheck-dumpfile%b and %Bcompile%b. Use %B-v%b to

View file

@ -53,7 +53,7 @@ _zimfw_mv() {
_zimfw_build_init() {
local -r ztarget=${ZIM_HOME}/init.zsh
# Force update of init.zsh if it's older than .zimrc
if [[ ${ztarget} -ot ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(
@ -99,7 +99,7 @@ _zimfw_build_init() {
_zimfw_build_login_init() {
local -r ztarget=${ZIM_HOME}/login_init.zsh
# Force update of login_init.zsh if it's older than .zimrc
if [[ ${ztarget} -ot ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then
command mv -f ${ztarget}{,.old} || return 1
fi
_zimfw_mv =(
@ -113,9 +113,10 @@ _zimfw_build() {
}
zmodule() {
local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc}
local -r zusage="Usage: %B${0}%b <url> [%B-n%b|%B--name%b <module_name>] [%B-r%b|%B--root%b <path>] [options]
Add %Bzmodule%b calls to your %B${ZDOTDIR:-${HOME}}/.zimrc%b file to define the modules to be initialized.
Add %Bzmodule%b calls to your %B${ztarget}%b file to define the modules to be initialized.
The initialization will be done in the same order it's defined.
<url> Module absolute path or repository URL. The following URL formats
@ -174,8 +175,8 @@ Per-call initialization options:
other per-call initialization options, so only your provided values will be used. I.e. these
values are either all automatic, or all manual in each zmodule call. To use default values
and also provided values, use separate zmodule calls."
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
print -u2 -PlR "%F{red}${0}: Must be called from %B${ZDOTDIR:-${HOME}}/.zimrc%b%f" '' ${zusage}
if [[ ${${funcfiletrace[1]%:*}:A} != ${ztarget:A} ]]; then
print -u2 -PlR "%F{red}${0}: Must be called from %B${ztarget}%b%f" '' ${zusage}
return 2
fi
if (( ! # )); then
@ -341,7 +342,7 @@ Per-call initialization options:
}
_zimfw_source_zimrc() {
local -r ztarget=${ZDOTDIR:-${HOME}}/.zimrc _zflags=${1}
local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} _zflags=${1}
local -i _zfailed=0
if ! source ${ztarget} || (( _zfailed )); then
print -u2 -PR "%F{red}Failed to source %B${ztarget}%b%f"
@ -454,7 +455,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2022-10-07 00:49:27 UTC, previous commit is 8a9d63c)'
print -R 'zimfw version: '${_zversion}' (built at 2022-10-24 00:21:20 UTC, previous commit is 3959a7f)'
print -R 'OSTYPE: '${OSTYPE}
print -R 'TERM: '${TERM}
print -R 'TERM_PROGRAM: '${TERM_PROGRAM}
@ -853,7 +854,7 @@ Actions:
%Bcompile%b Compile Zsh files.
%Bhelp%b Print this help.
%Binfo%b Print Zim and system info.
%Blist%b List all modules currently defined in %B${ZDOTDIR:-${HOME}}/.zimrc%b.
%Blist%b List all modules currently defined in %B${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc}%b.
Use %B-v%b to also see the modules details.
%Binit%b Same as %Binstall%b, but with output tailored to be used at terminal startup.
%Binstall%b Install new modules. Also does %Bbuild%b, %Bcheck-dumpfile%b and %Bcompile%b. Use %B-v%b to