1
0
Fork 0
mirror of synced 2024-09-27 21:16:56 -04:00

Compare commits

..

No commits in common. "master" and "v1.12.1" have entirely different histories.

21 changed files with 287 additions and 505 deletions

View file

@ -7,48 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed _No unreleased changes._
- Ask before uninstalling each unused module, instead of asking just once for
all.
## [1.14.0] - 2024-06-25
### Changed
- Don't expand `${HOME}` in the init.zsh script. (See
[#509](https://github.com/zimfw/zimfw/issues/509))
- Don't allow calling `zmodule` from the command line. Let it fail with "command
not found" instead, as it's intended to be used only in the .zimrc script.
- `ZIM_HOME` must be defined before sourcing zimfw.zsh. All documentation was
already doing so, hence not considering this as a breaking change.
- Allow zimfw.zsh to exist anywhere else, not only inside `ZIM_HOME`. This
enables installing the zimfw.zsh script independently with a package manager.
- Don't try to upgrade if sourced zimfw.zsh is not in a writable path.
- Don't try actions that write to `ZIM_HOME` if user has no write permissions
there.
### Fixed
- Update error messages to hopefully make it clearer when either the git or the
degit tool is being used.
- Set read permissions to generated init.zsh script, so it can be read from
other users.
## [1.13.1] - 2024-04-28
### Fixed
- The `--strip` option in tar command is not BSD compatible.
## [1.13.0] - 2024-02-17
### Added
- `--if-command` option to `zmodule`. This option is equivalent to
`--if "(( \${+commands[${1}]} ))"`.
- `mkdir` tool option in `zmodule` that creates an empty directory. This allows
creating modules that contain only externally generated files.
## [1.12.1] - 2023-09-16 ## [1.12.1] - 2023-09-16
@ -162,7 +121,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[here](https://github.com/zimfw/completion/blob/9386a76eac3f55b1c04d57d26238f725b4b3ba25/init.zsh#L10-L11). [here](https://github.com/zimfw/completion/blob/9386a76eac3f55b1c04d57d26238f725b4b3ba25/init.zsh#L10-L11).
- Don't compile user Zsh startup scripts anymore - Don't compile user Zsh startup scripts anymore
(See [#450](https://github.com/zimfw/zimfw/pull/450)). This means you can: (See [#450](https://github.com/zimfw/zimfw/pull/450)). This means you can:
- either manually delete the compiled files, as they won't be updated by zimfw - either manually delete the compiled files, as they won't be updated by Zim
anymore (recommended): anymore (recommended):
``` ```
for zfile in ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout); do for zfile in ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout); do
@ -363,7 +322,7 @@ Take your time to review the updated [README.md] and the changes listed below.
- The Zim "core" is reduced to a single file, namely zimfw.zsh, that is - The Zim "core" is reduced to a single file, namely zimfw.zsh, that is
self-updated without requiring git. With this, `ZIM_HOME` is not (the root of) self-updated without requiring git. With this, `ZIM_HOME` is not (the root of)
a git repo anymore. a git repo anymore.
- Zsh and modules are initialized in .zshrc instead of .zimrc. - Zsh and modules are configured in .zshrc instead of .zimrc.
- .zimrc is not sourced during Zsh startup anymore, and only contains the module - .zimrc is not sourced during Zsh startup anymore, and only contains the module
definitions. definitions.
- Zim's init.zsh and login_init.zsh scripts are generated by the `zimfw` CLI - Zim's init.zsh and login_init.zsh scripts are generated by the `zimfw` CLI
@ -402,10 +361,7 @@ Take your time to review the updated [README.md] and the changes listed below.
[termtitle]: https://github.com/zimfw/termtitle [termtitle]: https://github.com/zimfw/termtitle
[s1ck94]: https://github.com/zimfw/s1ck94 [s1ck94]: https://github.com/zimfw/s1ck94
[Unreleased]: https://github.com/zimfw/zimfw/compare/v1.14.0...HEAD [Unreleased]: https://github.com/zimfw/zimfw/compare/v1.12.1...HEAD
[1.14.0]: https://github.com/zimfw/zimfw/compare/v1.13.1...v1.14.0
[1.13.1]: https://github.com/zimfw/zimfw/compare/v1.13.0...v1.13.1
[1.13.0]: https://github.com/zimfw/zimfw/compare/v1.12.1...v1.13.0
[1.12.1]: https://github.com/zimfw/zimfw/compare/v1.12.0...v1.12.1 [1.12.1]: https://github.com/zimfw/zimfw/compare/v1.12.0...v1.12.1
[1.12.0]: https://github.com/zimfw/zimfw/compare/v1.11.3...v1.12.0 [1.12.0]: https://github.com/zimfw/zimfw/compare/v1.11.3...v1.12.0
[1.11.3]: https://github.com/zimfw/zimfw/compare/v1.11.2...v1.11.3 [1.11.3]: https://github.com/zimfw/zimfw/compare/v1.11.2...v1.11.3

View file

@ -1,7 +1,7 @@
MIT License MIT License
Copyright (c) 2015-2016 Matt Hamilton and contributors Copyright (c) 2015-2016 Matt Hamilton and contributors
Copyright (c) 2016-2024 Eric Nielsen, Matt Hamilton and contributors Copyright (c) 2016-2023 Eric Nielsen, Matt Hamilton and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

122
README.md
View file

@ -17,7 +17,7 @@
What is Zim? What is Zim?
------------ ------------
Zim is a Zsh configuration framework that bundles a [plugin manager](#usage), Zim is a Zsh configuration framework that bundles a [plugin manager](#usage),
useful [modules] and a wide variety of [themes], without compromising on [speed]. useful [modules], and a wide variety of [themes], without compromising on [speed].
Check how Zim compares to other frameworks and plugin managers: Check how Zim compares to other frameworks and plugin managers:
@ -47,17 +47,15 @@ Installing Zim is easy. You can choose either the automatic or manual method bel
This will install a predefined set of modules and a theme for you. This will install a predefined set of modules and a theme for you.
* With `curl`: * With `curl`:
```zsh
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
```
* With `wget`: * With `wget`:
```zsh
wget -nv -O - https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh wget -nv -O - https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
```
Restart your terminal and you're done. Enjoy your Zsh IMproved! Take some time Restart your terminal and you're done. Enjoy your Zsh IMproved! Take some time
to tweak your [`~/.zshrc`](#set-up-zshrc) file and to also check the available to tweak your [`~/.zshrc`](#set-up-zshrc) file, and to also check the available
[modules] and [themes] you can add to your [`~/.zimrc`](#create-zimrc). [modules] and [themes] you can add to your [`~/.zimrc`](#create-zimrc).
### Manual installation ### Manual installation
@ -81,27 +79,19 @@ Add the lines below to your `~/.zshrc` file, in the following order:
```zsh ```zsh
zstyle ':zim:zmodule' use 'degit' zstyle ':zim:zmodule' use 'degit'
```` ````
This is optional and only required if you don't have `git` installed (yes, This is optional, and only required if you don't have `git` installed (yes,
zimfw works even without `git`!) Zim works even without `git`!)
2. To set where the zimfw plugin manager configuration file will be located: 2. To set where the directory used by Zim will be located:
```zsh
ZIM_CONFIG_FILE=~/.config/zsh/zimrc
```
This is optional. The value of `ZIM_CONFIG_FILE` can be any path your user
has at least read access to. By default, the file must be at `~/.zimrc`, if
the `ZDOTDIR` environment variable is not defined. Otherwise, it must be at
`${ZDOTDIR}/.zimrc`.
3. To set the directory where the zimfw plugin manager will keep necessary files:
```zsh ```zsh
ZIM_HOME=~/.zim ZIM_HOME=~/.zim
``` ```
The value of `ZIM_HOME` can be any directory your user has write access to. The value of `ZIM_HOME` can be any directory your user has write access to.
You can even set it to a cache directory like `${XDG_CACHE_HOME}/zim` or You can even set it to a cache directory like `${XDG_CACHE_HOME}/zim` or
`~/.cache/zim`. `~/.cache/zim` if you also include the step below, that automatically
downloads the `zimfw` plugin manager.
4. To automatically download the zimfw plugin manager if missing: 3. To automatically download the `zimfw` plugin manager if missing:
```zsh ```zsh
# Download zimfw plugin manager if missing. # Download zimfw plugin manager if missing.
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
@ -117,27 +107,22 @@ Add the lines below to your `~/.zshrc` file, in the following order:
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
fi fi
``` ```
This is optional. Alternatively, you can download the `zimfw.zsh` script This is optional. If you choose to not include this step, you should manually
anywhere your user has write access to: just replace the occurrences of download the `zimfw.zsh` script once and keep it at `${ZIM_HOME}`.
`${ZIM_HOME}/zimfw.zsh` by the preferred path, like `/usr/local/bin/zimfw.zsh`
for example. If you choose to not include this step, you should manually
download the `zimfw.zsh` script once and keep it at the preferred path.
5. To automatically install missing modules and update the static initialization 4. To automatically install missing modules and update the static initialization
script if missing or outdated: script if missing or outdated:
```zsh ```zsh
# Install missing modules and update ${ZIM_HOME}/init.zsh if missing or outdated. # Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]]; then if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
source ${ZIM_HOME}/zimfw.zsh init -q source ${ZIM_HOME}/zimfw.zsh init -q
fi fi
``` ```
This step is optional, but highly recommended. If you choose to not include This step is optional, but highly recommended. If you choose to not include
it, you must remember to manually run `zimfw install` every time you update it, you must remember to manually run `zimfw install` every time after you
your [`~/.zimrc`](#create-zimrc) file. If you have chosen to keep the update your [`~/.zimrc`](#create-zimrc) file.
`zimfw.zsh` in a different path as mentioned in the previous step, replace
`${ZIM_HOME}/zimfw.zsh` by the chosen path.
6. To source the static script, that will initialize your modules: 5. To source the static script, that will initialize your modules:
```zsh ```zsh
# Initialize modules. # Initialize modules.
source ${ZIM_HOME}/init.zsh source ${ZIM_HOME}/init.zsh
@ -145,31 +130,18 @@ Add the lines below to your `~/.zshrc` file, in the following order:
#### Create `~/.zimrc` #### Create `~/.zimrc`
This file configures the zimfw plugin manager. It's referred to as `~/.zimrc` You must create your `.zimrc` file at `~/.zimrc`, if the `ZDOTDIR` environment
in the documentation for the sake of simplicity, but the actual location of the variable is not defined. Otherwise, it must be at `${ZDOTDIR}/.zimrc`. It's
file is defined by the following rules: referred to as `~/.zimrc` in the documentation for the sake of simplicity.
1. You can define the full path and name of the file with a `ZIM_CONFIG_FILE` You can start with just:
environment variable. For example:
```zsh
ZIM_CONFIG_FILE=~/.config/zsh/zimrc
```
2. Or, if you defined a `ZDOTDIR` environment variable, then the file must be at
`${ZDOTDIR}/.zimrc`
3. Otherwise, it must be at at `~/.zimrc`, which is it's default location.
As for the contents of the file, you can start with just:
```zsh ```zsh
zmodule zsh-users/zsh-syntax-highlighting zmodule zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-autosuggestions zmodule zsh-users/zsh-autosuggestions
``` ```
If you also want one of our prompt [themes]: If you also want one of our prompt [themes]:
```zsh ```
zmodule git-info
zmodule duration-info
zmodule asciiship zmodule asciiship
zmodule zsh-users/zsh-syntax-highlighting zmodule zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-autosuggestions zmodule zsh-users/zsh-autosuggestions
@ -177,8 +149,6 @@ zmodule zsh-users/zsh-autosuggestions
If you want to use our [completion] module too, instead of using `compinit` directly: If you want to use our [completion] module too, instead of using `compinit` directly:
```zsh ```zsh
zmodule git-info
zmodule duration-info
zmodule asciiship zmodule asciiship
zmodule zsh-users/zsh-completions --fpath src zmodule zsh-users/zsh-completions --fpath src
zmodule completion zmodule completion
@ -196,15 +166,15 @@ define the modules you want to use.
Usage Usage
----- -----
The zimfw plugin manager installs your modules at `${ZIM_HOME}/modules` and The `zimfw` plugin manager installs your modules at `${ZIM_HOME}/modules`, and
builds a static script at `${ZIM_HOME}/init.zsh` that will initialize them. Your builds a static script at `${ZIM_HOME}/init.zsh` that will initialize them. Your
modules are defined in your `~/.zimrc` file. modules are defined in your `~/.zimrc` file.
The `~/.zimrc` file must contain `zmodule` calls to define the modules to be The `~/.zimrc` file must contain `zmodule` calls to define the modules to be
initialized. The modules will be initialized in the same order they're defined. initialized. The initialization will be done in the same order it's defined.
The `~/.zimrc` file is not sourced during Zsh startup and it's only used to The `~/.zimrc` file is not sourced during Zsh startup, and it's only used to
configure the zimfw plugin manager. configure the `zimfw` plugin manager.
Check [examples of `~/.zimrc` files](#create-zimrc) above. Check [examples of `~/.zimrc` files](#create-zimrc) above.
@ -218,7 +188,7 @@ Below are some usage examples:
* A module at an absolute path, that is already installed: * A module at an absolute path, that is already installed:
`zmodule /usr/local/share/zsh-autosuggestions` `zmodule /usr/local/share/zsh-autosuggestions`
* A module with a custom fpath: `zmodule zsh-users/zsh-completions --fpath src` * A module with a custom fpath: `zmodule zsh-users/zsh-completions --fpath src`
* A module with a custom initialization file and with git submodules disabled: * A module with a custom initialization file, and with git submodules disabled:
`zmodule spaceship-prompt/spaceship-prompt --source spaceship.zsh --no-submodules` or `zmodule spaceship-prompt/spaceship-prompt --source spaceship.zsh --no-submodules` or
`zmodule spaceship-prompt/spaceship-prompt --name spaceship --no-submodules` `zmodule spaceship-prompt/spaceship-prompt --name spaceship --no-submodules`
* A module with two custom initialization files: * A module with two custom initialization files:
@ -257,7 +227,7 @@ zation will be done in the same order it's defined.
<url> Module absolute path or repository URL. The following URL formats <url> Module absolute path or repository URL. The following URL formats
are equivalent: <b>foo</b>, <b>zimfw/foo</b>, <b>https://github.com/zimfw/foo.git</b>. are equivalent: <b>foo</b>, <b>zimfw/foo</b>, <b>https://github.com/zimfw/foo.git</b>.
If an absolute path is given, the module is considered externally If an absolute path is given, the module is considered externally
installed and won&apos;t be installed or updated by zimfw. installed, and won&apos;t be installed or updated by zimfw.
<b>-n</b>|<b>--name</b> &lt;module_name&gt; Set a custom module name. Default: the last component in &lt;url&gt;. <b>-n</b>|<b>--name</b> &lt;module_name&gt; Set a custom module name. Default: the last component in &lt;url&gt;.
Slashes can be used inside the name to organize the module into Slashes can be used inside the name to organize the module into
subdirectories. The module will be installed at subdirectories. The module will be installed at
@ -269,16 +239,13 @@ Per-module options:
Overrides the tag option. Default: the repository default branch. Overrides the tag option. Default: the repository default branch.
<b>-t</b>|<b>--tag</b> &lt;tag_name&gt; Use specified tag when installing and updating the module. Over- <b>-t</b>|<b>--tag</b> &lt;tag_name&gt; Use specified tag when installing and updating the module. Over-
rides the branch option. rides the branch option.
<b>-u</b>|<b>--use</b> &lt;tool_name&gt; Install and update the module using the defined tool. Default is <b>-u</b>|<b>--use</b> &lt;<b>git</b>|<b>degit</b>&gt; Install and update the module using the defined tool. Default is
either defined by <b>zstyle &apos;:zim:zmodule&apos; use &apos;</b>&lt;tool_name&gt;<b>&apos;</b>, or <b>git</b> either defined by <b>zstyle &apos;:zim:zmodule&apos; use &apos;</b>&lt;<b>git</b>|<b>degit</b>&gt;<b>&apos;</b>, or <b>git</b>
if none is provided. The tools available are: if none is provided.
<b>git</b> uses the git command. Local changes are preserved on updates. <b>git</b> requires git itself. Local changes are preserved on updates.
<b>degit</b> uses curl or wget, and currently only works with GitHub <b>degit</b> requires curl or wget, and currently only works with GitHub
URLs. Modules install faster and take less disk space. Local URLs. Modules install faster and take less disk space. Local
changes are lost on updates. Git submodules are not supported. changes are lost on updates. Git submodules are not supported.
<b>mkdir</b> creates an empty directory. The &lt;url&gt; is only used to set
the module name. Use the <b>-c</b>|<b>--cmd</b> or <b>--on-pull</b> options to execute
the desired command to generate the module files.
<b>--no-submodules</b> Don&apos;t install or update git submodules. <b>--no-submodules</b> Don&apos;t install or update git submodules.
<b>-z</b>|<b>--frozen</b> Don&apos;t install or update the module. <b>-z</b>|<b>--frozen</b> Don&apos;t install or update the module.
@ -288,9 +255,6 @@ Per-module options:
Per-module-root options: Per-module-root options:
<b>--if</b> &lt;test&gt; Will only initialize module root if specified test returns a zero <b>--if</b> &lt;test&gt; Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup. exit status. The test is evaluated at every new terminal startup.
<b>--if-command</b> &lt;cmd_name&gt; Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to <b>--if &apos;(( ${+commands[</b>&lt;cmd_name&gt;<b>]} ))&apos;</b>.
<b>--on-pull</b> &lt;command&gt; Execute command after installing or updating the module. The com- <b>--on-pull</b> &lt;command&gt; Execute command after installing or updating the module. The com-
mand is executed in the module root directory. mand is executed in the module root directory.
<b>-d</b>|<b>--disabled</b> Don&apos;t initialize the module root or uninstall the module. <b>-d</b>|<b>--disabled</b> Don&apos;t initialize the module root or uninstall the module.
@ -329,17 +293,17 @@ The Zim plugin manager:
* Added new modules to `~/.zimrc`? Run `zimfw install`. * Added new modules to `~/.zimrc`? Run `zimfw install`.
* Removed modules from `~/.zimrc`? Run `zimfw uninstall`. * Removed modules from `~/.zimrc`? Run `zimfw uninstall`.
* Want to update your modules to their latest revisions? Run `zimfw update`. * Want to update your modules to their latest revisions? Run `zimfw update`.
* Want to upgrade zimfw to its latest version? Run `zimfw upgrade`. * Want to upgrade `zimfw` to its latest version? Run `zimfw upgrade`.
* For more information about the zimfw plugin manager, run `zimfw help`. * For more information about the `zimfw` plugin manager, run `zimfw help`.
Settings Settings
-------- --------
Set the path of the directory used by zimfw with the `ZIM_HOME` environment Customize path of the directory used by Zim with the `ZIM_HOME` environment
variable: variable:
ZIM_HOME=~/.zim ZIM_HOME=~/.zim
By default, the zimfw plugin manager configuration file must be at `~/.zimrc`, By default, the `zimfw` plugin manager configuration file must be at `~/.zimrc`,
if the `ZDOTDIR` environment variable is not defined. Otherwise, it must be at if the `ZDOTDIR` environment variable is not defined. Otherwise, it must be at
`${ZDOTDIR}/.zimrc`. You can customize its full path and name with the `${ZDOTDIR}/.zimrc`. You can customize its full path and name with the
`ZIM_CONFIG_FILE` environment variable: `ZIM_CONFIG_FILE` environment variable:
@ -352,10 +316,8 @@ lighter module installations, you can set degit as the default tool with:
zstyle ':zim:zmodule' use 'degit' zstyle ':zim:zmodule' use 'degit'
By default, zimfw will check if it has a new version available every 30 days. If By default, `zimfw` will check if it has a new version available every 30 days.
the `zimfw.zsh` file cannot be upgraded, either because your user does not have This can be disabled with:
write access to it, or because it was sourced from a symlink, then this will be
disabled. This can be manually disabled with:
zstyle ':zim' disable-version-check yes zstyle ':zim' disable-version-check yes

View file

@ -4,9 +4,5 @@ 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}$': <%= bold %>ZIM_HOME<%= normalred %> not defined<%= normal %>'
return 1
fi
# Define zimfw location # Define zimfw location
typeset -g __ZIMFW_FILE=${0} if (( ! ${+ZIM_HOME} )) typeset -g ZIM_HOME=${0:h}

View file

@ -7,6 +7,6 @@ _zimfw_mv() {
if [[ -e ${2} ]]; then if [[ -e ${2} ]]; then
command mv -f ${2}{,.old} || return 1 command mv -f ${2}{,.old} || return 1
fi fi
command mv -f ${1} ${2} && command chmod a+r ${2} && _zimfw_print -R $'<%= okay %><%= bold %>'${2}$':<%= normal %> Updated.'${_zrestartmsg} command mv -f ${1} ${2} && _zimfw_print -R $'<%= okay %><%= bold %>'${2}$':<%= normal %> Updated.'${_zrestartmsg}
fi fi
} }

View file

@ -5,7 +5,8 @@ _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 'if [[ -e ${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} ]] zimfw() { source '${${(qqq)__ZIMFW_FILE}/${HOME}/\${HOME}}' "${@}" }' print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R "zmodule() { source ${(q-)ZIM_HOME}/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})
@ -21,7 +22,7 @@ _zimfw_build_init() {
fi fi
done done
zpre=$'*\0' zpre=$'*\0'
if (( ${#_zfpaths} )) print -R 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})' if (( ${#_zfpaths} )) print -R 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}} if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0' zpre=${zroot_dir}$'\0'

View file

@ -8,7 +8,7 @@ The initialization will be done in the same order it\'s defined.
<url> Module absolute path or repository URL. The following URL formats <url> Module absolute path or repository URL. The following URL formats
are equivalent: <%= bold %>foo<%= normal %>, <%= bold %>zimfw/foo<%= normal %>, <%= bold %>https://github.com/zimfw/foo.git<%= normal %>. are equivalent: <%= bold %>foo<%= normal %>, <%= bold %>zimfw/foo<%= normal %>, <%= bold %>https://github.com/zimfw/foo.git<%= normal %>.
If an absolute path is given, the module is considered externally If an absolute path is given, the module is considered externally
installed and won\'t be installed or updated by zimfw. installed, and won\'t be installed or updated by zimfw.
<%= bold %>-n<%= normal %>|<%= bold %>--name<%= normal %> <module_name> Set a custom module name. Default: the last component in <url>. <%= bold %>-n<%= normal %>|<%= bold %>--name<%= normal %> <module_name> Set a custom module name. Default: the last component in <url>.
Slashes can be used inside the name to organize the module into Slashes can be used inside the name to organize the module into
subdirectories. The module will be installed at subdirectories. The module will be installed at
@ -20,16 +20,13 @@ Per-module options:
Overrides the tag option. Default: the repository default branch. Overrides the tag option. Default: the repository default branch.
<%= bold %>-t<%= normal %>|<%= bold %>--tag<%= normal %> <tag_name> Use specified tag when installing and updating the module. Over- <%= bold %>-t<%= normal %>|<%= bold %>--tag<%= normal %> <tag_name> Use specified tag when installing and updating the module. Over-
rides the branch option. rides the branch option.
<%= bold %>-u<%= normal %>|<%= bold %>--use<%= normal %> <tool_name> Install and update the module using the defined tool. Default is <%= bold %>-u<%= normal %>|<%= bold %>--use<%= normal %> <<%= bold %>git<%= normal %>|<%= bold %>degit<%= normal %>> Install and update the module using the defined tool. Default is
either defined by <%= bold %>zstyle \':zim:zmodule\' use \'<%= normal %><tool_name><%= bold %>\'<%= normal %>, or <%= bold %>git<%= normal %> either defined by <%= bold %>zstyle \':zim:zmodule\' use \'<%= normal %><<%= bold %>git<%= normal %>|<%= bold %>degit<%= normal %>><%= bold %>\'<%= normal %>, or <%= bold %>git<%= normal %>
if none is provided. The tools available are: if none is provided.
<%= bold %>git<%= normal %> uses the git command. Local changes are preserved on updates. <%= bold %>git<%= normal %> requires git itself. Local changes are preserved on updates.
<%= bold %>degit<%= normal %> uses curl or wget, and currently only works with GitHub <%= bold %>degit<%= normal %> requires curl or wget, and currently only works with GitHub
URLs. Modules install faster and take less disk space. Local URLs. Modules install faster and take less disk space. Local
changes are lost on updates. Git submodules are not supported. changes are lost on updates. Git submodules are not supported.
<%= bold %>mkdir<%= normal %> creates an empty directory. The <url> is only used to set
the module name. Use the <%= bold %>-c<%= normal %>|<%= bold %>--cmd<%= normal %> or <%= bold %>--on-pull<%= normal %> options to execute
the desired command to generate the module files.
<%= bold %>--no-submodules<%= normal %> Don\'t install or update git submodules. <%= bold %>--no-submodules<%= normal %> Don\'t install or update git submodules.
<%= bold %>-z<%= normal %>|<%= bold %>--frozen<%= normal %> Don\'t install or update the module. <%= bold %>-z<%= normal %>|<%= bold %>--frozen<%= normal %> Don\'t install or update the module.
@ -39,9 +36,6 @@ Per-module options:
Per-module-root options: Per-module-root options:
<%= bold %>--if<%= normal %> <test> Will only initialize module root if specified test returns a zero <%= bold %>--if<%= normal %> <test> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup. exit status. The test is evaluated at every new terminal startup.
<%= bold %>--if-command<%= normal %> <cmd_name> Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to <%= bold %>--if \'(( \${+commands[<%= normal %><cmd_name><%= bold %>]} ))\'<%= normal %>.
<%= bold %>--on-pull<%= normal %> <command> Execute command after installing or updating the module. The com- <%= bold %>--on-pull<%= normal %> <command> Execute command after installing or updating the module. The com-
mand is executed in the module root directory. mand is executed in the module root directory.
<%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module. <%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module.
@ -131,7 +125,7 @@ Per-call initialization options:
# Set values from options # Set values from options
while (( # > 0 )); do while (( # > 0 )); do
case ${1} in case ${1} in
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd) -b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage} print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
_zfailed=1 _zfailed=1
@ -171,10 +165,6 @@ Per-call initialization options:
shift shift
_zifs[${zroot_dir}]=${1} _zifs[${zroot_dir}]=${1}
;; ;;
--if-command)
shift
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
;;
-f|--fpath) -f|--fpath)
shift shift
zarg=${1} zarg=${1}
@ -189,11 +179,11 @@ Per-call initialization options:
shift shift
zarg=${1} zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg} if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
zcmds+=('source '${(qqq)zarg:a}) zcmds+=("source ${(q-)zarg:a}")
;; ;;
-c|--cmd) -c|--cmd)
shift shift
zcmds+=(${1//{}/${(qqq)zroot_dir:a}}) zcmds+=(${1//{}/${(q-)zroot_dir:a}})
;; ;;
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;; -d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
*) *)
@ -221,11 +211,11 @@ Per-call initialization options:
local -ra prezto_scripts=(${zroot_dir}/init.zsh(N)) local -ra prezto_scripts=(${zroot_dir}/init.zsh(N))
if (( ${#zfpaths} && ${#prezto_scripts} )); then if (( ${#zfpaths} && ${#prezto_scripts} )); then
# this follows the prezto module format, no need to check for other scripts # this follows the prezto module format, no need to check for other scripts
zcmds=('source '${(qqq)^prezto_scripts:a}) zcmds=('source '${(q-)^prezto_scripts:a})
else else
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first) # get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
zcmds=('source '${(qqq)^zscripts:a}) zcmds=('source '${(q-)^zscripts:a})
fi fi
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
@ -235,7 +225,6 @@ Per-call initialization options:
local -r zpre=${zroot_dir}$'\0' local -r zpre=${zroot_dir}$'\0'
_zfpaths+=(${zpre}${^zfpaths}) _zfpaths+=(${zpre}${^zfpaths})
_zfunctions+=(${zpre}${^zfunctions}) _zfunctions+=(${zpre}${^zfunctions})
zcmds=(${zcmds//${HOME}/\${HOME}})
_zcmds+=(${zpre}${^zcmds}) _zcmds+=(${zpre}${^zcmds})
fi fi
} }

View file

@ -1,25 +1,20 @@
_zimfw_source_zimrc() { _zimfw_source_zimrc() {
<%= render_all("src/functions/*.erb") %> local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1}
{ local -i _zfailed=0
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1} if ! source ${ztarget} || (( _zfailed )); then
local -i _zfailed=0 print -u2 -R $'<%= red %>Failed to source <%= bold %>'${ztarget}$'<%= normal %>'
if ! source ${ztarget} || (( _zfailed )); then return 1
print -u2 -R $'<%= red %>Failed to source <%= bold %>'${ztarget}$'<%= normal %>' fi
return 1 if (( _zflags & 1 && ${#_znames} == 0 )); then
fi print -u2 -R $'<%= red %>No modules defined in <%= bold %>'${ztarget}$'<%= normal %>'
if (( _zflags & 1 && ${#_znames} == 0 )); then return 1
print -u2 -R $'<%= red %>No modules defined in <%= bold %>'${ztarget}$'<%= normal %>' fi
return 1 # Remove all from _zfpaths, _zfunctions and _zcmds with disabled root dirs prefixes
fi local zroot_dir zpre
# Remove all from _zfpaths, _zfunctions and _zcmds with disabled root dirs prefixes for zroot_dir in ${_zdisabled_root_dirs}; do
local zroot_dir zpre zpre=${zroot_dir}$'\0'
for zroot_dir in ${_zdisabled_root_dirs}; do _zfpaths=(${_zfpaths:#${zpre}*})
zpre=${zroot_dir}$'\0' _zfunctions=(${_zfunctions:#${zpre}*})
_zfpaths=(${_zfpaths:#${zpre}*}) _zcmds=(${_zcmds:#${zpre}*})
_zfunctions=(${_zfunctions:#${zpre}*}) done
_zcmds=(${_zcmds:#${zpre}*})
done
} always {
unfunction zmodule
}
} }

View file

@ -1,17 +1,11 @@
_zimfw_uninstall() { _zimfw_uninstall() {
if (( _zprintlevel <= 0 )); then local zopt
command rm -rf ${_zunused_dirs} || return 1 if (( _zprintlevel > 0 )) zopt=-v
else if (( ${#_zunused_dirs} )); then
local zunused_dir if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#_zunused_dirs} module(s) listed above [y/N]? "; then
print $'Found <%= bold %>'${#_zunused_dirs}$'<%= normal %> unused module(s).' _zimfw_print
for zunused_dir in ${_zunused_dirs}; do command rm -rf ${zopt} ${_zunused_dirs} || return 1
if read -q "?Uninstall ${zunused_dir} [y/N]? "; then fi
print
command rm -rfv ${zunused_dir} || return 1
else
print
fi
done
print 'Done with uninstall.'
fi fi
_zimfw_print 'Done with uninstall.'
} }

View file

@ -1,9 +1,5 @@
_zimfw_upgrade() { _zimfw_upgrade() {
local -r ztarget=${__ZIMFW_FILE:A} zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz local -r ztarget=${ZIM_HOME}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
if [[ ! -w ${ztarget:h} ]]; then
print -u2 -R $'<%= red %>No write permission to <%= bold %>'${ztarget:h}$'<%= normalred %>. Will not try to upgrade.<%= normal %>'
return 1
fi
{ {
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

@ -8,19 +8,15 @@ _zimfw_run_list() {
print print
if (( _zprintlevel > 1 )); then if (( _zprintlevel > 1 )); then
if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then
if [[ ${_ztools[${zname}]} == mkdir ]]; then print -nR " From: ${_zurls[${zname}]}, "
print ' From: mkdir' if [[ -z ${_zrevs[${zname}]} ]]; then
print -n 'default branch'
else else
print -nR " From: ${_zurls[${zname}]}, " print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
if [[ -z ${_zrevs[${zname}]} ]]; then
print -n 'default branch'
else
print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
fi
print -nR ", using ${_ztools[${zname}]}"
if (( ! _zsubmodules[${zname}] )) print -n ', no git submodules'
print
fi fi
print -nR ", using ${_ztools[${zname}]}"
if (( ! _zsubmodules[${zname}] )) print -n ', no git submodules'
print
if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}" if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}"
fi fi
# Match the current module dir prefix from _zroot_dirs # Match the current module dir prefix from _zroot_dirs

View file

@ -1,6 +0,0 @@
_zimfw_create_dir() {
if ! ERR=$(command mkdir -p ${1} 2>&1); then
_zimfw_print_error "Error creating ${1}" ${ERR}
return 1
fi
}

View file

@ -1,3 +0,0 @@
_zimfw_print_warn() {
_zimfw_print -u2 -R $'<%= clear_line %><%= yellow %><%= warn %><%= bold %>'${_zname}$':<%= normalyellow %> '${1}$'<%= normal %>'
}

View file

@ -4,16 +4,22 @@ _zimfw_download_tarball() {
readonly REPO=${match[4]%.git} readonly REPO=${match[4]%.git}
fi fi
if [[ ${HOST} != github.com || -z ${REPO} ]]; then if [[ ${HOST} != github.com || -z ${REPO} ]]; then
_zimfw_print_error ${URL}$' is not a valid URL. Will not try to '${ACTION}$'. The zimfw degit tool only supports GitHub URLs. Use zmodule option <%= bold %>--use git<%= normalred %> to use git instead.' _zimfw_print_error "${URL} is not a valid GitHub URL. Will not try to ${_zaction}."
return 1 return 1
fi fi
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
{ {
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}") if [[ -r ${INFO_TARGET} ]]; then
# Previous REV is in line 2, reserved for future use. readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
readonly INFO_HEADER=${INFO[3]} if [[ ${URL} != ${INFO[1]} ]]; then
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
return 1
fi
# Previous REV is in line 2, reserved for future use.
readonly INFO_HEADER=${INFO[3]}
fi
readonly TARBALL_URL=https://api.github.com/repos/${REPO}/tarball/${REV} readonly TARBALL_URL=https://api.github.com/repos/${REPO}/tarball/${REV}
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
if [[ -z ${INFO_HEADER} ]] return 0 if [[ -z ${INFO_HEADER} ]] return 0
if (( ${+commands[curl]} )); then if (( ${+commands[curl]} )); then
command curl -IfsL -H ${INFO_HEADER} ${TARBALL_URL} >${HEADERS_TARGET} command curl -IfsL -H ${INFO_HEADER} ${TARBALL_URL} >${HEADERS_TARGET}
@ -51,7 +57,7 @@ _zimfw_download_tarball() {
_zimfw_print_error "Error downloading ${TARBALL_URL}, no ETag header found in response" _zimfw_print_error "Error downloading ${TARBALL_URL}, no ETag header found in response"
return 1 return 1
fi fi
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
command touch ${TARBALL_TARGET} # Update available command touch ${TARBALL_TARGET} # Update available
else else
if ! print -lR "${URL}" "${REV}" "If-None-Match: ${ETAG}" >! ${INFO_TARGET} 2>/dev/null; then if ! print -lR "${URL}" "${REV}" "If-None-Match: ${ETAG}" >! ${INFO_TARGET} 2>/dev/null; then
@ -65,39 +71,25 @@ _zimfw_download_tarball() {
} }
_zimfw_untar_tarball() { _zimfw_untar_tarball() {
if ! ERR=$(command tar -C ${1} -xzf ${TARBALL_TARGET} 2>&1); then if ! ERR=$(command tar -C ${1} --strip=1 -xzf ${TARBALL_TARGET} 2>&1); then
_zimfw_print_error "Error extracting ${TARBALL_TARGET}" ${ERR} _zimfw_print_error "Error extracting ${TARBALL_TARGET}" ${ERR}
return 1 return 1
fi fi
local zsubdir }
for zsubdir in ${1}/*(/); do
if ! ERR=$(command mv -f ${zsubdir}/*(DN) ${1} 2>&1 && command rmdir ${zsubdir} 2>&1); then _zimfw_create_dir() {
_zimfw_print_error "Error moving ${zsubdir}" ${ERR} if ! ERR=$(command mkdir -p ${1} 2>&1); then
return 1 _zimfw_print_error "Error creating ${1}" ${ERR}
fi return 1
done fi
} }
_zimfw_tool_degit() { _zimfw_tool_degit() {
# This runs in a subshell # This runs in a subshell
readonly -i SUBMODULES=${6} readonly -i SUBMODULES=${5}
readonly ACTION=${1} DIR=${2} URL=${3} REV=${5} ONPULL=${7} TEMP=.zdegit_${sysparams[pid]} readonly DIR=${1} URL=${2} REV=${4} ONPULL=${6} TEMP=.zdegit_${sysparams[pid]}
readonly TARBALL_TARGET=${DIR}/${TEMP}_tarball.tar.gz INFO_TARGET=${DIR}/.zdegit readonly TARBALL_TARGET=${DIR}/${TEMP}_tarball.tar.gz INFO_TARGET=${DIR}/.zdegit
case ${ACTION} in case ${_zaction} in
pre)
if [[ -e ${DIR} ]]; then
if [[ ! -r ${INFO_TARGET} ]]; then
_zimfw_print_error $'Module was not installed using zimfw\'s degit. Use zmodule option <%= bold %>-z<%= normalred %>|<%= bold %>--frozen<%= normalred %> to disable this error.'
return 1
fi
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
if [[ ${URL} != ${INFO[1]} ]]; then
_zimfw_print_error 'The zimfw degit URL does not match. Expected '${URL}$'. Use zmodule option <%= bold %>-z<%= normalred %>|<%= bold %>--frozen<%= normalred %> to disable this error.'
return 1
fi
fi
return 0
;;
install) install)
{ {
_zimfw_create_dir ${DIR} && _zimfw_download_tarball && _zimfw_untar_tarball ${DIR} && _zimfw_pull_print_okay Installed || return 1 _zimfw_create_dir ${DIR} && _zimfw_download_tarball && _zimfw_untar_tarball ${DIR} && _zimfw_pull_print_okay Installed || return 1
@ -109,10 +101,14 @@ _zimfw_tool_degit() {
} }
;; ;;
check|update) check|update)
if [[ ! -r ${INFO_TARGET} ]]; then
_zimfw_print -u2 -R $'<%= clear_line %><%= yellow %><%= warn %><%= bold %>'${_zname}$':<%= normalyellow %> Module was not installed using zimfw\'s degit. Will not try to '${_zaction}$'. Use zmodule option <%= bold %>-z<%= normalyellow %>|<%= bold %>--frozen<%= normalyellow %> to disable this warning.<%= normal %>'
return 0
fi
readonly DIR_NEW=${DIR}${TEMP} readonly DIR_NEW=${DIR}${TEMP}
{ {
_zimfw_download_tarball || return 1 _zimfw_download_tarball || return 1
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
if [[ -e ${TARBALL_TARGET} ]]; then if [[ -e ${TARBALL_TARGET} ]]; then
_zimfw_print_okay 'Update available' _zimfw_print_okay 'Update available'
return 4 return 4
@ -143,7 +139,7 @@ _zimfw_tool_degit() {
;; ;;
esac esac
# Check after successful install or update # Check after successful install or update
if [[ ${SUBMODULES} -ne 0 && -e ${DIR}/.gitmodules ]]; then if [[ ${_zprintlevel} -gt 0 && ${SUBMODULES} -ne 0 && -e ${DIR}/.gitmodules ]]; then
_zimfw_print_warn $'Module contains git submodules, which are not supported by zimfw\'s degit. Use zmodule option <%= bold %>--no-submodules<%= normalyellow %> to disable this warning.' print -u2 -R $'<%= clear_line %><%= yellow %><%= warn %><%= bold %>'${_zname}$':<%= normalyellow %> Module contains git submodules, which are not supported by zimfw\'s degit. Use zmodule option <%= bold %>--no-submodules<%= normalyellow %> to disable this warning.<%= normal %>'
fi fi
} }

View file

@ -1,21 +1,9 @@
_zimfw_tool_git() { _zimfw_tool_git() {
# This runs in a subshell # This runs in a subshell
readonly -i SUBMODULES=${6} readonly -i SUBMODULES=${5}
readonly ACTION=${1} DIR=${2} URL=${3} TYPE=${4} ONPULL=${7} readonly DIR=${1} URL=${2} TYPE=${3} ONPULL=${6}
REV=${5} REV=${4}
case ${ACTION} in case ${_zaction} in
pre)
if [[ -e ${DIR} ]]; then
if [[ ! -r ${DIR}/.git ]]; then
_zimfw_print_error $'Module was not installed using git. Use zmodule option <%= bold %>-z<%= normalred %>|<%= bold %>--frozen<%= normalred %> to disable this error.'
return 1
fi
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
_zimfw_print_error 'The git URL does not match. Expected '${URL}.$' Use zmodule option <%= bold %>-z<%= normalred %>|<%= bold %>--frozen<%= normalred %> to disable this error.'
return 1
fi
fi
;;
install) install)
if ERR=$(command git clone ${REV:+-b} ${REV} -q --config core.autocrlf=false ${${SUBMODULES:#0}:+--recursive} -- ${URL} ${DIR} 2>&1); then if ERR=$(command git clone ${REV:+-b} ${REV} -q --config core.autocrlf=false ${${SUBMODULES:#0}:+--recursive} -- ${URL} ${DIR} 2>&1); then
_zimfw_pull_print_okay Installed _zimfw_pull_print_okay Installed
@ -25,6 +13,14 @@ _zimfw_tool_git() {
fi fi
;; ;;
check|update) check|update)
if [[ ! -r ${DIR}/.git ]]; then
_zimfw_print -u2 -R $'<%= clear_line %><%= yellow %><%= warn %><%= bold %>'${_zname}$':<%= normalyellow %> Module was not installed using git. Will not try to '${_zaction}$'. Use zmodule option <%= bold %>-z<%= normalyellow %>|<%= bold %>--frozen<%= normalyellow %> to disable this warning.<%= normal %>'
return 0
fi
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
return 1
fi
if ! ERR=$(command git -C ${DIR} fetch -pqt origin 2>&1); then if ! ERR=$(command git -C ${DIR} fetch -pqt origin 2>&1); then
_zimfw_print_error 'Error during git fetch' ${ERR} _zimfw_print_error 'Error during git fetch' ${ERR}
return 1 return 1
@ -44,7 +40,7 @@ _zimfw_tool_git() {
fi fi
fi fi
TO_REV=${REV}@{u} TO_REV=${REV}@{u}
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
readonly -i BEHIND=$(command git -C ${DIR} rev-list --count ${REV}..${TO_REV} -- 2>/dev/null) readonly -i BEHIND=$(command git -C ${DIR} rev-list --count ${REV}..${TO_REV} -- 2>/dev/null)
if (( BEHIND )); then if (( BEHIND )); then
_zimfw_print_okay "Update available [behind ${BEHIND}]" _zimfw_print_okay "Update available [behind ${BEHIND}]"
@ -56,7 +52,7 @@ _zimfw_tool_git() {
fi fi
else else
if [[ ${REV} == $(command git -C ${DIR} describe --tags --exact-match 2>/dev/null) ]]; then if [[ ${REV} == $(command git -C ${DIR} describe --tags --exact-match 2>/dev/null) ]]; then
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
_zimfw_print_okay 'Already up to date' 1 _zimfw_print_okay 'Already up to date' 1
return 0 return 0
else else
@ -64,7 +60,7 @@ _zimfw_tool_git() {
return ${?} return ${?}
fi fi
fi fi
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
_zimfw_print_okay 'Update available' _zimfw_print_okay 'Update available'
return 4 return 4
fi fi

View file

@ -1,15 +0,0 @@
_zimfw_tool_mkdir() {
# This runs in a subshell
readonly -i SUBMODULES=${6}
readonly ACTION=${1} DIR=${2} TYPE=${4} REV=${5} ONPULL=${7}
if [[ ${ACTION} == pre ]] return 0
if [[ -n ${REV} ]]; then
_zimfw_print_warn $'The zmodule option <%= bold %>-'${TYPE[1]}$'<%= normalyellow %>|<%= bold %>--'${TYPE}$'<%= normalyellow %> has no effect when using the mkdir tool'
fi
if (( ! SUBMODULES )); then
_zimfw_print_warn $'The zmodule option <%= bold %>--no-submodules<%= normalyellow %> has no effect when using the mkdir tool'
fi
if [[ ! -d ${DIR} || -n ${ONPULL} ]]; then
_zimfw_create_dir ${DIR} && _zimfw_pull_print_okay Created || return 1
fi
}

View file

@ -8,13 +8,6 @@ _zimfw_run_tool() {
_zimfw_print_okay 'Skipping frozen module' 1 _zimfw_print_okay 'Skipping frozen module' 1
return 0 return 0
fi fi
local -r ztool=${_ztools[${_zname}]}
if [[ ${ztool} != (degit|git|mkdir) ]]; then
_zimfw_print_error "Unknown tool ${ztool}"
return 1
fi
set "${_zdirs[${_zname}]}" "${_zurls[${_zname}]}" "${_ztypes[${_zname}]}" "${_zrevs[${_zname}]}" "${_zsubmodules[${_zname}]}" "${_zonpulls[${_zname}]}"
_zimfw_tool_${ztool} pre "${@}" || return 1
case ${_zaction} in case ${_zaction} in
install) install)
if [[ -e ${_zdirs[${_zname}]} ]]; then if [[ -e ${_zdirs[${_zname}]} ]]; then
@ -39,5 +32,14 @@ _zimfw_run_tool() {
return 1 return 1
;; ;;
esac esac
_zimfw_tool_${ztool} ${_zaction} "${@}" local -r ztool=${_ztools[${_zname}]}
case ${ztool} in
degit|git)
_zimfw_tool_${ztool} "${_zdirs[${_zname}]}" "${_zurls[${_zname}]}" "${_ztypes[${_zname}]}" "${_zrevs[${_zname}]}" "${_zsubmodules[${_zname}]}" "${_zonpulls[${_zname}]}"
;;
*)
_zimfw_print_error "Unknown tool ${ztool}"
return 1
;;
esac
} }

View file

@ -1,6 +1,5 @@
_zimfw_run_tool_action() { _zimfw_run_tool_action() {
local -r _zaction=${1} local -r _zaction=${1}
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
return 0 return 0
} }

View file

@ -1,6 +1,6 @@
zimfw() { zimfw() {
builtin emulate -L zsh -o EXTENDED_GLOB builtin emulate -L zsh -o EXTENDED_GLOB
local -r _zversion='<%= version %>' zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <action> [<%= bold %>-q<%= normal %>|<%= bold %>-v<%= normal %>] local -r _zversion='<%= version %>' _zversion_target=${ZIM_HOME}/.latest_version zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <action> [<%= bold %>-q<%= normal %>|<%= bold %>-v<%= normal %>]
Actions: Actions:
<%= bold %>build<%= normal %> Build <%= bold %>'${ZIM_HOME}$'/init.zsh<%= normal %> and <%= bold %>'${ZIM_HOME}$'/login_init.zsh<%= normal %>. <%= bold %>build<%= normal %> Build <%= bold %>'${ZIM_HOME}$'/init.zsh<%= normal %> and <%= bold %>'${ZIM_HOME}$'/login_init.zsh<%= normal %>.
@ -46,19 +46,12 @@ Options:
esac esac
fi fi
local -r _zversion_target=${ZIM_HOME}/.latest_version if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
if ! zstyle -t ':zim' disable-version-check && \
[[ ${1} != check-version && -w ${ZIM_HOME} && -w ${__ZIMFW_FILE:A:h} ]]
then
# If .latest_version does not exist or was not modified in the last 30 days # If .latest_version does not exist or was not modified in the last 30 days
[[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?} [[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?}
_zimfw_check_version ${zversion_check_force} 1 _zimfw_check_version ${zversion_check_force} 1
fi fi
if [[ ! -w ${ZIM_HOME} && ${1} == (build|check|init|install|update|check-version) ]]; then
print -u2 -R $'<%= red %>'${0}$': No write permission to <%= bold %>'${ZIM_HOME}$'<%= normalred %>. Will not try to '${1}$'.<%= normal %>'
return 1
fi
local _zrestartmsg=' Restart your terminal for changes to take effect.' local _zrestartmsg=' Restart your terminal for changes to take effect.'
case ${1} in case ${1} in
build) build)
@ -67,10 +60,10 @@ Options:
_zimfw_compile _zimfw_compile
;; ;;
check-dumpfile) _zimfw_check_dumpfile ;; check-dumpfile) _zimfw_check_dumpfile ;;
clean) _zimfw_source_zimrc 0 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;; clean) _zimfw_source_zimrc 2 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
clean-compiled) _zimfw_source_zimrc 0 && _zimfw_clean_compiled ;; clean-compiled) _zimfw_source_zimrc 2 && _zimfw_clean_compiled ;;
clean-dumpfile) _zimfw_clean_dumpfile ;; clean-dumpfile) _zimfw_clean_dumpfile ;;
compile) _zimfw_source_zimrc 0 && _zimfw_compile ;; compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
help) print -R ${zusage} ;; help) print -R ${zusage} ;;
info) _zimfw_info ;; info) _zimfw_info ;;
list) list)
@ -96,12 +89,12 @@ Options:
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile _zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
;; ;;
uninstall) _zimfw_source_zimrc 0 && _zimfw_list_unuseds && _zimfw_uninstall ;; uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
check-version) _zimfw_check_version 1 ;; check-version) _zimfw_check_version 1 ;;
upgrade) upgrade)
_zimfw_upgrade || return 1 _zimfw_upgrade || return 1
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc 0 && _zimfw_compile _zimfw_source_zimrc 2 && _zimfw_compile
;; ;;
version) print -R ${_zversion} ;; version) print -R ${_zversion} ;;
*) *)

View file

@ -4,7 +4,7 @@ class Zim
:bold, :normal, :red, :normalred, :yellow, :normalyellow, :clear_line, :ellipsis, :okay, :warn, :error :bold, :normal, :red, :normalred, :yellow, :normalyellow, :clear_line, :ellipsis, :okay, :warn, :error
def initialize def initialize
@version = "1.15.0-SNAPSHOT" @version = "1.12.1"
@home = "${ZDOTDIR:-${HOME}}" @home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2" @min_zsh_version = "5.2"
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo # Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo
@ -42,4 +42,8 @@ zim = Zim.new
<%= zim.render_commented("LICENSE") %> <%= zim.render_commented("LICENSE") %>
<%= zim.render_all("src/stage2/*.erb") %> <%= zim.render_all("src/stage2/*.erb") %>
zimfw "${@}" if [[ ${functrace[1]} == zmodule:* ]]; then
zmodule "${@}"
else
zimfw "${@}"
fi

311
zimfw.zsh
View file

@ -4,7 +4,7 @@
# MIT License # MIT License
# #
# Copyright (c) 2015-2016 Matt Hamilton and contributors # Copyright (c) 2015-2016 Matt Hamilton and contributors
# Copyright (c) 2016-2024 Eric Nielsen, Matt Hamilton and contributors # Copyright (c) 2016-2023 Eric Nielsen, Matt Hamilton and contributors
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -30,12 +30,8 @@ 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}$': \E[1mZIM_HOME\E[0;31m not defined\E[0m'
return 1
fi
# Define zimfw location # Define zimfw location
typeset -g __ZIMFW_FILE=${0} if (( ! ${+ZIM_HOME} )) typeset -g ZIM_HOME=${0:h}
_zimfw_print() { _zimfw_print() {
if (( _zprintlevel > 0 )) print "${@}" if (( _zprintlevel > 0 )) print "${@}"
@ -50,7 +46,7 @@ _zimfw_mv() {
if [[ -e ${2} ]]; then if [[ -e ${2} ]]; then
command mv -f ${2}{,.old} || return 1 command mv -f ${2}{,.old} || return 1
fi fi
command mv -f ${1} ${2} && command chmod a+r ${2} && _zimfw_print -R $'\E[32m)\E[0m \E[1m'${2}$':\E[0m Updated.'${_zrestartmsg} command mv -f ${1} ${2} && _zimfw_print -R $'\E[32m)\E[0m \E[1m'${2}$':\E[0m Updated.'${_zrestartmsg}
fi fi
} }
@ -61,7 +57,8 @@ _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 'if [[ -e ${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} ]] zimfw() { source '${${(qqq)__ZIMFW_FILE}/${HOME}/\${HOME}}' "${@}" }' print -R "zimfw() { source ${(q-)ZIM_HOME}/zimfw.zsh \"\${@}\" }"
print -R "zmodule() { source ${(q-)ZIM_HOME}/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})
@ -77,7 +74,7 @@ _zimfw_build_init() {
fi fi
done done
zpre=$'*\0' zpre=$'*\0'
if (( ${#_zfpaths} )) print -R 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})' if (( ${#_zfpaths} )) print -R 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}} if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
for zroot_dir in ${_zroot_dirs}; do for zroot_dir in ${_zroot_dirs}; do
zpre=${zroot_dir}$'\0' zpre=${zroot_dir}$'\0'
@ -113,7 +110,6 @@ _zimfw_build() {
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.' _zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
} }
_zimfw_source_zimrc() {
zmodule() { zmodule() {
local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc}
local -r zusage=$'Usage: \E[1m'${0}$'\E[0m <url> [\E[1m-n\E[0m|\E[1m--name\E[0m <module_name>] [\E[1m-r\E[0m|\E[1m--root\E[0m <path>] [options] local -r zusage=$'Usage: \E[1m'${0}$'\E[0m <url> [\E[1m-n\E[0m|\E[1m--name\E[0m <module_name>] [\E[1m-r\E[0m|\E[1m--root\E[0m <path>] [options]
@ -124,7 +120,7 @@ The initialization will be done in the same order it\'s defined.
<url> Module absolute path or repository URL. The following URL formats <url> Module absolute path or repository URL. The following URL formats
are equivalent: \E[1mfoo\E[0m, \E[1mzimfw/foo\E[0m, \E[1mhttps://github.com/zimfw/foo.git\E[0m. are equivalent: \E[1mfoo\E[0m, \E[1mzimfw/foo\E[0m, \E[1mhttps://github.com/zimfw/foo.git\E[0m.
If an absolute path is given, the module is considered externally If an absolute path is given, the module is considered externally
installed and won\'t be installed or updated by zimfw. installed, and won\'t be installed or updated by zimfw.
\E[1m-n\E[0m|\E[1m--name\E[0m <module_name> Set a custom module name. Default: the last component in <url>. \E[1m-n\E[0m|\E[1m--name\E[0m <module_name> Set a custom module name. Default: the last component in <url>.
Slashes can be used inside the name to organize the module into Slashes can be used inside the name to organize the module into
subdirectories. The module will be installed at subdirectories. The module will be installed at
@ -136,16 +132,13 @@ Per-module options:
Overrides the tag option. Default: the repository default branch. Overrides the tag option. Default: the repository default branch.
\E[1m-t\E[0m|\E[1m--tag\E[0m <tag_name> Use specified tag when installing and updating the module. Over- \E[1m-t\E[0m|\E[1m--tag\E[0m <tag_name> Use specified tag when installing and updating the module. Over-
rides the branch option. rides the branch option.
\E[1m-u\E[0m|\E[1m--use\E[0m <tool_name> Install and update the module using the defined tool. Default is \E[1m-u\E[0m|\E[1m--use\E[0m <\E[1mgit\E[0m|\E[1mdegit\E[0m> Install and update the module using the defined tool. Default is
either defined by \E[1mzstyle \':zim:zmodule\' use \'\E[0m<tool_name>\E[1m\'\E[0m, or \E[1mgit\E[0m either defined by \E[1mzstyle \':zim:zmodule\' use \'\E[0m<\E[1mgit\E[0m|\E[1mdegit\E[0m>\E[1m\'\E[0m, or \E[1mgit\E[0m
if none is provided. The tools available are: if none is provided.
\E[1mgit\E[0m uses the git command. Local changes are preserved on updates. \E[1mgit\E[0m requires git itself. Local changes are preserved on updates.
\E[1mdegit\E[0m uses curl or wget, and currently only works with GitHub \E[1mdegit\E[0m requires curl or wget, and currently only works with GitHub
URLs. Modules install faster and take less disk space. Local URLs. Modules install faster and take less disk space. Local
changes are lost on updates. Git submodules are not supported. changes are lost on updates. Git submodules are not supported.
\E[1mmkdir\E[0m creates an empty directory. The <url> is only used to set
the module name. Use the \E[1m-c\E[0m|\E[1m--cmd\E[0m or \E[1m--on-pull\E[0m options to execute
the desired command to generate the module files.
\E[1m--no-submodules\E[0m Don\'t install or update git submodules. \E[1m--no-submodules\E[0m Don\'t install or update git submodules.
\E[1m-z\E[0m|\E[1m--frozen\E[0m Don\'t install or update the module. \E[1m-z\E[0m|\E[1m--frozen\E[0m Don\'t install or update the module.
@ -155,9 +148,6 @@ Per-module options:
Per-module-root options: Per-module-root options:
\E[1m--if\E[0m <test> Will only initialize module root if specified test returns a zero \E[1m--if\E[0m <test> Will only initialize module root if specified test returns a zero
exit status. The test is evaluated at every new terminal startup. exit status. The test is evaluated at every new terminal startup.
\E[1m--if-command\E[0m <cmd_name> Will only initialize module root if specified external command is
available. This is evaluated at every new terminal startup.
Equivalent to \E[1m--if \'(( \${+commands[\E[0m<cmd_name>\E[1m]} ))\'\E[0m.
\E[1m--on-pull\E[0m <command> Execute command after installing or updating the module. The com- \E[1m--on-pull\E[0m <command> Execute command after installing or updating the module. The com-
mand is executed in the module root directory. mand is executed in the module root directory.
\E[1m-d\E[0m|\E[1m--disabled\E[0m Don\'t initialize the module root or uninstall the module. \E[1m-d\E[0m|\E[1m--disabled\E[0m Don\'t initialize the module root or uninstall the module.
@ -247,7 +237,7 @@ Per-call initialization options:
# Set values from options # Set values from options
while (( # > 0 )); do while (( # > 0 )); do
case ${1} in case ${1} in
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd) -b|--branch|-t|--tag|-u|--use|--on-pull|--if|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -lR $'\E[31mx '${funcfiletrace[1]}$':\E[1m'${zname}$':\E[0;31m Missing argument for zmodule option \E[1m'${1}$'\E[0m' '' ${zusage} print -u2 -lR $'\E[31mx '${funcfiletrace[1]}$':\E[1m'${zname}$':\E[0;31m Missing argument for zmodule option \E[1m'${1}$'\E[0m' '' ${zusage}
_zfailed=1 _zfailed=1
@ -287,10 +277,6 @@ Per-call initialization options:
shift shift
_zifs[${zroot_dir}]=${1} _zifs[${zroot_dir}]=${1}
;; ;;
--if-command)
shift
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
;;
-f|--fpath) -f|--fpath)
shift shift
zarg=${1} zarg=${1}
@ -305,11 +291,11 @@ Per-call initialization options:
shift shift
zarg=${1} zarg=${1}
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg} if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
zcmds+=('source '${(qqq)zarg:a}) zcmds+=("source ${(q-)zarg:a}")
;; ;;
-c|--cmd) -c|--cmd)
shift shift
zcmds+=(${1//{}/${(qqq)zroot_dir:a}}) zcmds+=(${1//{}/${(q-)zroot_dir:a}})
;; ;;
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;; -d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
*) *)
@ -337,11 +323,11 @@ Per-call initialization options:
local -ra prezto_scripts=(${zroot_dir}/init.zsh(N)) local -ra prezto_scripts=(${zroot_dir}/init.zsh(N))
if (( ${#zfpaths} && ${#prezto_scripts} )); then if (( ${#zfpaths} && ${#prezto_scripts} )); then
# this follows the prezto module format, no need to check for other scripts # this follows the prezto module format, no need to check for other scripts
zcmds=('source '${(qqq)^prezto_scripts:a}) zcmds=('source '${(q-)^prezto_scripts:a})
else else
# get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first) # get script with largest size (descending `O`rder by `L`ength, and return only `[1]` first)
local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1])) local -ra zscripts=(${zroot_dir}/(init.zsh|(${zname:t}|${zroot_dir:t}).(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
zcmds=('source '${(qqq)^zscripts:a}) zcmds=('source '${(q-)^zscripts:a})
fi fi
fi fi
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
@ -351,33 +337,29 @@ Per-call initialization options:
local -r zpre=${zroot_dir}$'\0' local -r zpre=${zroot_dir}$'\0'
_zfpaths+=(${zpre}${^zfpaths}) _zfpaths+=(${zpre}${^zfpaths})
_zfunctions+=(${zpre}${^zfunctions}) _zfunctions+=(${zpre}${^zfunctions})
zcmds=(${zcmds//${HOME}/\${HOME}})
_zcmds+=(${zpre}${^zcmds}) _zcmds+=(${zpre}${^zcmds})
fi fi
} }
{ _zimfw_source_zimrc() {
local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} _zflags=${1} local -r ztarget=${ZIM_CONFIG_FILE:-${ZDOTDIR:-${HOME}}/.zimrc} _zflags=${1}
local -i _zfailed=0 local -i _zfailed=0
if ! source ${ztarget} || (( _zfailed )); then if ! source ${ztarget} || (( _zfailed )); then
print -u2 -R $'\E[31mFailed to source \E[1m'${ztarget}$'\E[0m' print -u2 -R $'\E[31mFailed to source \E[1m'${ztarget}$'\E[0m'
return 1 return 1
fi fi
if (( _zflags & 1 && ${#_znames} == 0 )); then if (( _zflags & 1 && ${#_znames} == 0 )); then
print -u2 -R $'\E[31mNo modules defined in \E[1m'${ztarget}$'\E[0m' print -u2 -R $'\E[31mNo modules defined in \E[1m'${ztarget}$'\E[0m'
return 1 return 1
fi fi
# Remove all from _zfpaths, _zfunctions and _zcmds with disabled root dirs prefixes # Remove all from _zfpaths, _zfunctions and _zcmds with disabled root dirs prefixes
local zroot_dir zpre local zroot_dir zpre
for zroot_dir in ${_zdisabled_root_dirs}; do for zroot_dir in ${_zdisabled_root_dirs}; do
zpre=${zroot_dir}$'\0' zpre=${zroot_dir}$'\0'
_zfpaths=(${_zfpaths:#${zpre}*}) _zfpaths=(${_zfpaths:#${zpre}*})
_zfunctions=(${_zfunctions:#${zpre}*}) _zfunctions=(${_zfunctions:#${zpre}*})
_zcmds=(${_zcmds:#${zpre}*}) _zcmds=(${_zcmds:#${zpre}*})
done done
} always {
unfunction zmodule
}
} }
_zimfw_list_unuseds() { _zimfw_list_unuseds() {
@ -462,7 +444,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2024-09-16 23:27:18 UTC, previous commit is 3fe3ba2)' print -R 'zimfw version: '${_zversion}' (built at 2023-09-16 18:25:16 UTC, previous commit is 26151d2)'
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}
@ -470,29 +452,19 @@ _zimfw_info() {
} }
_zimfw_uninstall() { _zimfw_uninstall() {
if (( _zprintlevel <= 0 )); then local zopt
command rm -rf ${_zunused_dirs} || return 1 if (( _zprintlevel > 0 )) zopt=-v
else if (( ${#_zunused_dirs} )); then
local zunused_dir if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#_zunused_dirs} module(s) listed above [y/N]? "; then
print $'Found \E[1m'${#_zunused_dirs}$'\E[0m unused module(s).' _zimfw_print
for zunused_dir in ${_zunused_dirs}; do command rm -rf ${zopt} ${_zunused_dirs} || return 1
if read -q "?Uninstall ${zunused_dir} [y/N]? "; then fi
print
command rm -rfv ${zunused_dir} || return 1
else
print
fi
done
print 'Done with uninstall.'
fi fi
_zimfw_print 'Done with uninstall.'
} }
_zimfw_upgrade() { _zimfw_upgrade() {
local -r ztarget=${__ZIMFW_FILE:A} zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz local -r ztarget=${ZIM_HOME}/zimfw.zsh zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
if [[ ! -w ${ztarget:h} ]]; then
print -u2 -R $'\E[31mNo write permission to \E[1m'${ztarget:h}$'\E[0;31m. Will not try to upgrade.\E[0m'
return 1
fi
{ {
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
@ -526,19 +498,15 @@ _zimfw_run_list() {
print print
if (( _zprintlevel > 1 )); then if (( _zprintlevel > 1 )); then
if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then
if [[ ${_ztools[${zname}]} == mkdir ]]; then print -nR " From: ${_zurls[${zname}]}, "
print ' From: mkdir' if [[ -z ${_zrevs[${zname}]} ]]; then
print -n 'default branch'
else else
print -nR " From: ${_zurls[${zname}]}, " print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
if [[ -z ${_zrevs[${zname}]} ]]; then
print -n 'default branch'
else
print -nR "${_ztypes[${zname}]} ${_zrevs[${zname}]}"
fi
print -nR ", using ${_ztools[${zname}]}"
if (( ! _zsubmodules[${zname}] )) print -n ', no git submodules'
print
fi fi
print -nR ", using ${_ztools[${zname}]}"
if (( ! _zsubmodules[${zname}] )) print -n ', no git submodules'
print
if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}" if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}"
fi fi
# Match the current module dir prefix from _zroot_dirs # Match the current module dir prefix from _zroot_dirs
@ -561,13 +529,6 @@ _zimfw_run_list() {
fi fi
} }
_zimfw_create_dir() {
if ! ERR=$(command mkdir -p ${1} 2>&1); then
_zimfw_print_error "Error creating ${1}" ${ERR}
return 1
fi
}
_zimfw_print_error() { _zimfw_print_error() {
print -u2 -lR $'\E[2K\r\E[31mx \E[1m'${_zname}$':\E[0;31m '${1}$'\E[0m' ${2:+${(F):- ${(f)^2}}} print -u2 -lR $'\E[2K\r\E[31mx \E[1m'${_zname}$':\E[0;31m '${1}$'\E[0m' ${2:+${(F):- ${(f)^2}}}
} }
@ -576,10 +537,6 @@ _zimfw_print_okay() {
if (( _zprintlevel > ${2:-0} )) print -lR $'\E[2K\r\E[32m)\E[0m \E[1m'${_zname}$':\E[0m '${1} ${3:+${(F):- ${(f)^3}}} if (( _zprintlevel > ${2:-0} )) print -lR $'\E[2K\r\E[32m)\E[0m \E[1m'${_zname}$':\E[0m '${1} ${3:+${(F):- ${(f)^3}}}
} }
_zimfw_print_warn() {
_zimfw_print -u2 -R $'\E[2K\r\E[33m! \E[1m'${_zname}$':\E[0;33m '${1}$'\E[0m'
}
_zimfw_pull_print_okay() { _zimfw_pull_print_okay() {
# Useb by tools, which run in a subshell # Useb by tools, which run in a subshell
if [[ -n ${ONPULL} ]]; then if [[ -n ${ONPULL} ]]; then
@ -600,16 +557,22 @@ _zimfw_download_tarball() {
readonly REPO=${match[4]%.git} readonly REPO=${match[4]%.git}
fi fi
if [[ ${HOST} != github.com || -z ${REPO} ]]; then if [[ ${HOST} != github.com || -z ${REPO} ]]; then
_zimfw_print_error ${URL}$' is not a valid URL. Will not try to '${ACTION}$'. The zimfw degit tool only supports GitHub URLs. Use zmodule option \E[1m--use git\E[0;31m to use git instead.' _zimfw_print_error "${URL} is not a valid GitHub URL. Will not try to ${_zaction}."
return 1 return 1
fi fi
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
{ {
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}") if [[ -r ${INFO_TARGET} ]]; then
# Previous REV is in line 2, reserved for future use. readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
readonly INFO_HEADER=${INFO[3]} if [[ ${URL} != ${INFO[1]} ]]; then
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
return 1
fi
# Previous REV is in line 2, reserved for future use.
readonly INFO_HEADER=${INFO[3]}
fi
readonly TARBALL_URL=https://api.github.com/repos/${REPO}/tarball/${REV} readonly TARBALL_URL=https://api.github.com/repos/${REPO}/tarball/${REV}
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
if [[ -z ${INFO_HEADER} ]] return 0 if [[ -z ${INFO_HEADER} ]] return 0
if (( ${+commands[curl]} )); then if (( ${+commands[curl]} )); then
command curl -IfsL -H ${INFO_HEADER} ${TARBALL_URL} >${HEADERS_TARGET} command curl -IfsL -H ${INFO_HEADER} ${TARBALL_URL} >${HEADERS_TARGET}
@ -647,7 +610,7 @@ _zimfw_download_tarball() {
_zimfw_print_error "Error downloading ${TARBALL_URL}, no ETag header found in response" _zimfw_print_error "Error downloading ${TARBALL_URL}, no ETag header found in response"
return 1 return 1
fi fi
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
command touch ${TARBALL_TARGET} # Update available command touch ${TARBALL_TARGET} # Update available
else else
if ! print -lR "${URL}" "${REV}" "If-None-Match: ${ETAG}" >! ${INFO_TARGET} 2>/dev/null; then if ! print -lR "${URL}" "${REV}" "If-None-Match: ${ETAG}" >! ${INFO_TARGET} 2>/dev/null; then
@ -661,39 +624,25 @@ _zimfw_download_tarball() {
} }
_zimfw_untar_tarball() { _zimfw_untar_tarball() {
if ! ERR=$(command tar -C ${1} -xzf ${TARBALL_TARGET} 2>&1); then if ! ERR=$(command tar -C ${1} --strip=1 -xzf ${TARBALL_TARGET} 2>&1); then
_zimfw_print_error "Error extracting ${TARBALL_TARGET}" ${ERR} _zimfw_print_error "Error extracting ${TARBALL_TARGET}" ${ERR}
return 1 return 1
fi fi
local zsubdir }
for zsubdir in ${1}/*(/); do
if ! ERR=$(command mv -f ${zsubdir}/*(DN) ${1} 2>&1 && command rmdir ${zsubdir} 2>&1); then _zimfw_create_dir() {
_zimfw_print_error "Error moving ${zsubdir}" ${ERR} if ! ERR=$(command mkdir -p ${1} 2>&1); then
return 1 _zimfw_print_error "Error creating ${1}" ${ERR}
fi return 1
done fi
} }
_zimfw_tool_degit() { _zimfw_tool_degit() {
# This runs in a subshell # This runs in a subshell
readonly -i SUBMODULES=${6} readonly -i SUBMODULES=${5}
readonly ACTION=${1} DIR=${2} URL=${3} REV=${5} ONPULL=${7} TEMP=.zdegit_${sysparams[pid]} readonly DIR=${1} URL=${2} REV=${4} ONPULL=${6} TEMP=.zdegit_${sysparams[pid]}
readonly TARBALL_TARGET=${DIR}/${TEMP}_tarball.tar.gz INFO_TARGET=${DIR}/.zdegit readonly TARBALL_TARGET=${DIR}/${TEMP}_tarball.tar.gz INFO_TARGET=${DIR}/.zdegit
case ${ACTION} in case ${_zaction} in
pre)
if [[ -e ${DIR} ]]; then
if [[ ! -r ${INFO_TARGET} ]]; then
_zimfw_print_error $'Module was not installed using zimfw\'s degit. Use zmodule option \E[1m-z\E[0;31m|\E[1m--frozen\E[0;31m to disable this error.'
return 1
fi
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
if [[ ${URL} != ${INFO[1]} ]]; then
_zimfw_print_error 'The zimfw degit URL does not match. Expected '${URL}$'. Use zmodule option \E[1m-z\E[0;31m|\E[1m--frozen\E[0;31m to disable this error.'
return 1
fi
fi
return 0
;;
install) install)
{ {
_zimfw_create_dir ${DIR} && _zimfw_download_tarball && _zimfw_untar_tarball ${DIR} && _zimfw_pull_print_okay Installed || return 1 _zimfw_create_dir ${DIR} && _zimfw_download_tarball && _zimfw_untar_tarball ${DIR} && _zimfw_pull_print_okay Installed || return 1
@ -705,10 +654,14 @@ _zimfw_tool_degit() {
} }
;; ;;
check|update) check|update)
if [[ ! -r ${INFO_TARGET} ]]; then
_zimfw_print -u2 -R $'\E[2K\r\E[33m! \E[1m'${_zname}$':\E[0;33m Module was not installed using zimfw\'s degit. Will not try to '${_zaction}$'. Use zmodule option \E[1m-z\E[0;33m|\E[1m--frozen\E[0;33m to disable this warning.\E[0m'
return 0
fi
readonly DIR_NEW=${DIR}${TEMP} readonly DIR_NEW=${DIR}${TEMP}
{ {
_zimfw_download_tarball || return 1 _zimfw_download_tarball || return 1
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
if [[ -e ${TARBALL_TARGET} ]]; then if [[ -e ${TARBALL_TARGET} ]]; then
_zimfw_print_okay 'Update available' _zimfw_print_okay 'Update available'
return 4 return 4
@ -739,29 +692,17 @@ _zimfw_tool_degit() {
;; ;;
esac esac
# Check after successful install or update # Check after successful install or update
if [[ ${SUBMODULES} -ne 0 && -e ${DIR}/.gitmodules ]]; then if [[ ${_zprintlevel} -gt 0 && ${SUBMODULES} -ne 0 && -e ${DIR}/.gitmodules ]]; then
_zimfw_print_warn $'Module contains git submodules, which are not supported by zimfw\'s degit. Use zmodule option \E[1m--no-submodules\E[0;33m to disable this warning.' print -u2 -R $'\E[2K\r\E[33m! \E[1m'${_zname}$':\E[0;33m Module contains git submodules, which are not supported by zimfw\'s degit. Use zmodule option \E[1m--no-submodules\E[0;33m to disable this warning.\E[0m'
fi fi
} }
_zimfw_tool_git() { _zimfw_tool_git() {
# This runs in a subshell # This runs in a subshell
readonly -i SUBMODULES=${6} readonly -i SUBMODULES=${5}
readonly ACTION=${1} DIR=${2} URL=${3} TYPE=${4} ONPULL=${7} readonly DIR=${1} URL=${2} TYPE=${3} ONPULL=${6}
REV=${5} REV=${4}
case ${ACTION} in case ${_zaction} in
pre)
if [[ -e ${DIR} ]]; then
if [[ ! -r ${DIR}/.git ]]; then
_zimfw_print_error $'Module was not installed using git. Use zmodule option \E[1m-z\E[0;31m|\E[1m--frozen\E[0;31m to disable this error.'
return 1
fi
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
_zimfw_print_error 'The git URL does not match. Expected '${URL}.$' Use zmodule option \E[1m-z\E[0;31m|\E[1m--frozen\E[0;31m to disable this error.'
return 1
fi
fi
;;
install) install)
if ERR=$(command git clone ${REV:+-b} ${REV} -q --config core.autocrlf=false ${${SUBMODULES:#0}:+--recursive} -- ${URL} ${DIR} 2>&1); then if ERR=$(command git clone ${REV:+-b} ${REV} -q --config core.autocrlf=false ${${SUBMODULES:#0}:+--recursive} -- ${URL} ${DIR} 2>&1); then
_zimfw_pull_print_okay Installed _zimfw_pull_print_okay Installed
@ -771,6 +712,14 @@ _zimfw_tool_git() {
fi fi
;; ;;
check|update) check|update)
if [[ ! -r ${DIR}/.git ]]; then
_zimfw_print -u2 -R $'\E[2K\r\E[33m! \E[1m'${_zname}$':\E[0;33m Module was not installed using git. Will not try to '${_zaction}$'. Use zmodule option \E[1m-z\E[0;33m|\E[1m--frozen\E[0;33m to disable this warning.\E[0m'
return 0
fi
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
return 1
fi
if ! ERR=$(command git -C ${DIR} fetch -pqt origin 2>&1); then if ! ERR=$(command git -C ${DIR} fetch -pqt origin 2>&1); then
_zimfw_print_error 'Error during git fetch' ${ERR} _zimfw_print_error 'Error during git fetch' ${ERR}
return 1 return 1
@ -790,7 +739,7 @@ _zimfw_tool_git() {
fi fi
fi fi
TO_REV=${REV}@{u} TO_REV=${REV}@{u}
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
readonly -i BEHIND=$(command git -C ${DIR} rev-list --count ${REV}..${TO_REV} -- 2>/dev/null) readonly -i BEHIND=$(command git -C ${DIR} rev-list --count ${REV}..${TO_REV} -- 2>/dev/null)
if (( BEHIND )); then if (( BEHIND )); then
_zimfw_print_okay "Update available [behind ${BEHIND}]" _zimfw_print_okay "Update available [behind ${BEHIND}]"
@ -802,7 +751,7 @@ _zimfw_tool_git() {
fi fi
else else
if [[ ${REV} == $(command git -C ${DIR} describe --tags --exact-match 2>/dev/null) ]]; then if [[ ${REV} == $(command git -C ${DIR} describe --tags --exact-match 2>/dev/null) ]]; then
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
_zimfw_print_okay 'Already up to date' 1 _zimfw_print_okay 'Already up to date' 1
return 0 return 0
else else
@ -810,7 +759,7 @@ _zimfw_tool_git() {
return ${?} return ${?}
fi fi
fi fi
if [[ ${ACTION} == check ]]; then if [[ ${_zaction} == check ]]; then
_zimfw_print_okay 'Update available' _zimfw_print_okay 'Update available'
return 4 return 4
fi fi
@ -842,22 +791,6 @@ _zimfw_tool_git() {
esac esac
} }
_zimfw_tool_mkdir() {
# This runs in a subshell
readonly -i SUBMODULES=${6}
readonly ACTION=${1} DIR=${2} TYPE=${4} REV=${5} ONPULL=${7}
if [[ ${ACTION} == pre ]] return 0
if [[ -n ${REV} ]]; then
_zimfw_print_warn $'The zmodule option \E[1m-'${TYPE[1]}$'\E[0;33m|\E[1m--'${TYPE}$'\E[0;33m has no effect when using the mkdir tool'
fi
if (( ! SUBMODULES )); then
_zimfw_print_warn $'The zmodule option \E[1m--no-submodules\E[0;33m has no effect when using the mkdir tool'
fi
if [[ ! -d ${DIR} || -n ${ONPULL} ]]; then
_zimfw_create_dir ${DIR} && _zimfw_pull_print_okay Created || return 1
fi
}
_zimfw_run_tool() { _zimfw_run_tool() {
local -r _zname=${1} local -r _zname=${1}
if [[ -z ${_zurls[${_zname}]} ]]; then if [[ -z ${_zurls[${_zname}]} ]]; then
@ -868,13 +801,6 @@ _zimfw_run_tool() {
_zimfw_print_okay 'Skipping frozen module' 1 _zimfw_print_okay 'Skipping frozen module' 1
return 0 return 0
fi fi
local -r ztool=${_ztools[${_zname}]}
if [[ ${ztool} != (degit|git|mkdir) ]]; then
_zimfw_print_error "Unknown tool ${ztool}"
return 1
fi
set "${_zdirs[${_zname}]}" "${_zurls[${_zname}]}" "${_ztypes[${_zname}]}" "${_zrevs[${_zname}]}" "${_zsubmodules[${_zname}]}" "${_zonpulls[${_zname}]}"
_zimfw_tool_${ztool} pre "${@}" || return 1
case ${_zaction} in case ${_zaction} in
install) install)
if [[ -e ${_zdirs[${_zname}]} ]]; then if [[ -e ${_zdirs[${_zname}]} ]]; then
@ -899,19 +825,27 @@ _zimfw_run_tool() {
return 1 return 1
;; ;;
esac esac
_zimfw_tool_${ztool} ${_zaction} "${@}" local -r ztool=${_ztools[${_zname}]}
case ${ztool} in
degit|git)
_zimfw_tool_${ztool} "${_zdirs[${_zname}]}" "${_zurls[${_zname}]}" "${_ztypes[${_zname}]}" "${_zrevs[${_zname}]}" "${_zsubmodules[${_zname}]}" "${_zonpulls[${_zname}]}"
;;
*)
_zimfw_print_error "Unknown tool ${ztool}"
return 1
;;
esac
} }
_zimfw_run_tool_action() { _zimfw_run_tool_action() {
local -r _zaction=${1} local -r _zaction=${1}
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
return 0 return 0
} }
zimfw() { zimfw() {
builtin emulate -L zsh -o EXTENDED_GLOB builtin emulate -L zsh -o EXTENDED_GLOB
local -r _zversion='1.15.0-SNAPSHOT' zusage=$'Usage: \E[1m'${0}$'\E[0m <action> [\E[1m-q\E[0m|\E[1m-v\E[0m] local -r _zversion='1.12.1' _zversion_target=${ZIM_HOME}/.latest_version zusage=$'Usage: \E[1m'${0}$'\E[0m <action> [\E[1m-q\E[0m|\E[1m-v\E[0m]
Actions: Actions:
\E[1mbuild\E[0m Build \E[1m'${ZIM_HOME}$'/init.zsh\E[0m and \E[1m'${ZIM_HOME}$'/login_init.zsh\E[0m. \E[1mbuild\E[0m Build \E[1m'${ZIM_HOME}$'/init.zsh\E[0m and \E[1m'${ZIM_HOME}$'/login_init.zsh\E[0m.
@ -957,19 +891,12 @@ Options:
esac esac
fi fi
local -r _zversion_target=${ZIM_HOME}/.latest_version if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
if ! zstyle -t ':zim' disable-version-check && \
[[ ${1} != check-version && -w ${ZIM_HOME} && -w ${__ZIMFW_FILE:A:h} ]]
then
# If .latest_version does not exist or was not modified in the last 30 days # If .latest_version does not exist or was not modified in the last 30 days
[[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?} [[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?}
_zimfw_check_version ${zversion_check_force} 1 _zimfw_check_version ${zversion_check_force} 1
fi fi
if [[ ! -w ${ZIM_HOME} && ${1} == (build|check|init|install|update|check-version) ]]; then
print -u2 -R $'\E[31m'${0}$': No write permission to \E[1m'${ZIM_HOME}$'\E[0;31m. Will not try to '${1}$'.\E[0m'
return 1
fi
local _zrestartmsg=' Restart your terminal for changes to take effect.' local _zrestartmsg=' Restart your terminal for changes to take effect.'
case ${1} in case ${1} in
build) build)
@ -978,10 +905,10 @@ Options:
_zimfw_compile _zimfw_compile
;; ;;
check-dumpfile) _zimfw_check_dumpfile ;; check-dumpfile) _zimfw_check_dumpfile ;;
clean) _zimfw_source_zimrc 0 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;; clean) _zimfw_source_zimrc 2 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
clean-compiled) _zimfw_source_zimrc 0 && _zimfw_clean_compiled ;; clean-compiled) _zimfw_source_zimrc 2 && _zimfw_clean_compiled ;;
clean-dumpfile) _zimfw_clean_dumpfile ;; clean-dumpfile) _zimfw_clean_dumpfile ;;
compile) _zimfw_source_zimrc 0 && _zimfw_compile ;; compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
help) print -R ${zusage} ;; help) print -R ${zusage} ;;
info) _zimfw_info ;; info) _zimfw_info ;;
list) list)
@ -1007,12 +934,12 @@ Options:
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile _zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
;; ;;
uninstall) _zimfw_source_zimrc 0 && _zimfw_list_unuseds && _zimfw_uninstall ;; uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
check-version) _zimfw_check_version 1 ;; check-version) _zimfw_check_version 1 ;;
upgrade) upgrade)
_zimfw_upgrade || return 1 _zimfw_upgrade || return 1
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc 0 && _zimfw_compile _zimfw_source_zimrc 2 && _zimfw_compile
;; ;;
version) print -R ${_zversion} ;; version) print -R ${_zversion} ;;
*) *)
@ -1022,4 +949,8 @@ Options:
esac esac
} }
zimfw "${@}" if [[ ${functrace[1]} == zmodule:* ]]; then
zmodule "${@}"
else
zimfw "${@}"
fi