Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
|
6166fce1a1 | ||
|
3b7908dca1 | ||
|
0785d87ea4 | ||
|
eb37844857 | ||
|
3e812ed311 | ||
|
897afc9cf9 | ||
|
76164d6217 | ||
|
9a47fde0c8 | ||
|
06f8bc71a3 | ||
|
9dc4056c4e | ||
|
96f60da366 | ||
|
cdd9258d5c | ||
|
4fcc85b2db | ||
|
4200e6cdb3 | ||
|
c86223f473 |
39
CHANGELOG.md
39
CHANGELOG.md
|
@ -9,11 +9,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
_No unreleased changes._
|
_No unreleased changes._
|
||||||
|
|
||||||
|
## [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
|
## [1.13.0] - 2024-02-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `--if-command` option to zmodule. This option is equivalent to
|
- `--if-command` option to `zmodule`. This option is equivalent to
|
||||||
`--if "(( \${+commands[${1}]} ))"`.
|
`--if "(( \${+commands[${1}]} ))"`.
|
||||||
- `mkdir` tool option in `zmodule` that creates an empty directory. This allows
|
- `mkdir` tool option in `zmodule` that creates an empty directory. This allows
|
||||||
creating modules that contain only externally generated files.
|
creating modules that contain only externally generated files.
|
||||||
|
@ -130,7 +159,7 @@ _No unreleased changes._
|
||||||
[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 Zim
|
- either manually delete the compiled files, as they won't be updated by zimfw
|
||||||
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
|
||||||
|
@ -331,7 +360,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 configured in .zshrc instead of .zimrc.
|
- Zsh and modules are initialized 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
|
||||||
|
@ -370,7 +399,9 @@ 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.13.0...HEAD
|
[Unreleased]: https://github.com/zimfw/zimfw/compare/v1.14.0...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.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
|
||||||
|
|
100
README.md
100
README.md
|
@ -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,15 +47,17 @@ 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
|
||||||
|
@ -79,19 +81,27 @@ 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,
|
||||||
Zim works even without `git`!)
|
zimfw works even without `git`!)
|
||||||
|
|
||||||
2. To set where the directory used by Zim will be located:
|
2. To set where the zimfw plugin manager configuration file 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` if you also include the step below, that automatically
|
`~/.cache/zim`.
|
||||||
downloads the `zimfw` plugin manager.
|
|
||||||
|
|
||||||
3. To automatically download the `zimfw` plugin manager if missing:
|
4. 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
|
||||||
|
@ -107,22 +117,27 @@ 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. If you choose to not include this step, you should manually
|
This is optional. Alternatively, you can download the `zimfw.zsh` script
|
||||||
download the `zimfw.zsh` script once and keep it at `${ZIM_HOME}`.
|
anywhere your user has write access to: just replace the occurrences of
|
||||||
|
`${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.
|
||||||
|
|
||||||
4. To automatically install missing modules and update the static initialization
|
5. 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 ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
|
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZIM_CONFIG_FILE:-${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 after you
|
it, you must remember to manually run `zimfw install` every time you update
|
||||||
update your [`~/.zimrc`](#create-zimrc) file.
|
your [`~/.zimrc`](#create-zimrc) file. If you have chosen to keep the
|
||||||
|
`zimfw.zsh` in a different path as mentioned in the previous step, replace
|
||||||
|
`${ZIM_HOME}/zimfw.zsh` by the chosen path.
|
||||||
|
|
||||||
5. To source the static script, that will initialize your modules:
|
6. 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
|
||||||
|
@ -130,18 +145,31 @@ Add the lines below to your `~/.zshrc` file, in the following order:
|
||||||
|
|
||||||
#### Create `~/.zimrc`
|
#### Create `~/.zimrc`
|
||||||
|
|
||||||
You must create your `.zimrc` file at `~/.zimrc`, if the `ZDOTDIR` environment
|
This file configures the zimfw plugin manager. It's referred to as `~/.zimrc`
|
||||||
variable is not defined. Otherwise, it must be at `${ZDOTDIR}/.zimrc`. It's
|
in the documentation for the sake of simplicity, but the actual location of the
|
||||||
referred to as `~/.zimrc` in the documentation for the sake of simplicity.
|
file is defined by the following rules:
|
||||||
|
|
||||||
You can start with just:
|
1. You can define the full path and name of the file with a `ZIM_CONFIG_FILE`
|
||||||
|
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
|
||||||
|
@ -149,6 +177,8 @@ 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
|
||||||
|
@ -166,15 +196,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 initialization will be done in the same order it's defined.
|
initialized. The modules will be initialized in the same order they're 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.
|
||||||
|
|
||||||
|
@ -188,7 +218,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:
|
||||||
|
@ -299,17 +329,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
|
||||||
--------
|
--------
|
||||||
Customize path of the directory used by Zim with the `ZIM_HOME` environment
|
Set the path of the directory used by zimfw 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:
|
||||||
|
@ -322,8 +352,10 @@ 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.
|
By default, zimfw will check if it has a new version available every 30 days. If
|
||||||
This can be disabled with:
|
the `zimfw.zsh` file cannot be upgraded, either because your user does not have
|
||||||
|
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
|
||||||
|
|
||||||
|
|
|
@ -189,11 +189,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 ${(q-)zarg:a}")
|
zcmds+=('source '${(qqq)zarg:a})
|
||||||
;;
|
;;
|
||||||
-c|--cmd)
|
-c|--cmd)
|
||||||
shift
|
shift
|
||||||
zcmds+=(${1//{}/${(q-)zroot_dir:a}})
|
zcmds+=(${1//{}/${(qqq)zroot_dir:a}})
|
||||||
;;
|
;;
|
||||||
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
|
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
|
||||||
*)
|
*)
|
||||||
|
@ -221,11 +221,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 '${(q-)^prezto_scripts:a})
|
zcmds=('source '${(qqq)^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 '${(q-)^zscripts:a})
|
zcmds=('source '${(qqq)^zscripts:a})
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||||
|
@ -235,6 +235,7 @@ 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
|
||||||
}
|
}
|
|
@ -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}$': <%= bold %>ZIM_HOME<%= normalred %> not defined<%= normal %>'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
# Define zimfw location
|
# Define zimfw location
|
||||||
if (( ! ${+ZIM_HOME} )) typeset -g ZIM_HOME=${0:h}
|
typeset -g __ZIMFW_FILE=${0}
|
||||||
|
|
|
@ -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} && _zimfw_print -R $'<%= okay %><%= bold %>'${2}$':<%= normal %> Updated.'${_zrestartmsg}
|
command mv -f ${1} ${2} && command chmod a+r ${2} && _zimfw_print -R $'<%= okay %><%= bold %>'${2}$':<%= normal %> Updated.'${_zrestartmsg}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +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 'if (( ${+ZIM_HOME} )) zimfw() { source '${${(qqq)__ZIMFW_FILE}/${HOME}/\${HOME}}' "${@}" }'
|
||||||
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})
|
||||||
|
@ -22,7 +21,7 @@ _zimfw_build_init() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
zpre=$'*\0'
|
zpre=$'*\0'
|
||||||
if (( ${#_zfpaths} )) print -R 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
|
if (( ${#_zfpaths} )) print -R 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${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'
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
_zimfw_source_zimrc() {
|
_zimfw_source_zimrc() {
|
||||||
|
<%= render_all("src/functions/*.erb") %>
|
||||||
|
{
|
||||||
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1}
|
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1}
|
||||||
local -i _zfailed=0
|
local -i _zfailed=0
|
||||||
if ! source ${ztarget} || (( _zfailed )); then
|
if ! source ${ztarget} || (( _zfailed )); then
|
||||||
|
@ -17,4 +19,7 @@ _zimfw_source_zimrc() {
|
||||||
_zfunctions=(${_zfunctions:#${zpre}*})
|
_zfunctions=(${_zfunctions:#${zpre}*})
|
||||||
_zcmds=(${_zcmds:#${zpre}*})
|
_zcmds=(${_zcmds:#${zpre}*})
|
||||||
done
|
done
|
||||||
|
} always {
|
||||||
|
unfunction zmodule
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
_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_FILE:A} 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
|
||||||
|
|
|
@ -4,7 +4,7 @@ _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 GitHub URL. Will not try to ${_zaction}."
|
_zimfw_print_error ${URL}$' is not a valid URL. Will not try to '${_zaction}$'. The zimfw degit tool only supports GitHub URLs. Use zmodule option <%= bold %>--use git<%= normalred %> to use git instead.'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
|
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
|
||||||
|
@ -12,7 +12,7 @@ _zimfw_download_tarball() {
|
||||||
if [[ -r ${INFO_TARGET} ]]; then
|
if [[ -r ${INFO_TARGET} ]]; then
|
||||||
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
|
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
|
||||||
if [[ ${URL} != ${INFO[1]} ]]; then
|
if [[ ${URL} != ${INFO[1]} ]]; then
|
||||||
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
_zimfw_print_error "The zimfw degit URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Previous REV is in line 2, reserved for future use.
|
# Previous REV is in line 2, reserved for future use.
|
||||||
|
@ -71,10 +71,17 @@ _zimfw_download_tarball() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_untar_tarball() {
|
_zimfw_untar_tarball() {
|
||||||
if ! ERR=$(command tar -C ${1} --strip=1 -xzf ${TARBALL_TARGET} 2>&1); then
|
if ! ERR=$(command tar -C ${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_print_error "Error moving ${zsubdir}" ${ERR}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_tool_degit() {
|
_zimfw_tool_degit() {
|
||||||
|
|
|
@ -18,7 +18,7 @@ _zimfw_tool_git() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
|
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}."
|
_zimfw_print_error "The git URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
_zimfw_run_tool_action() {
|
_zimfw_run_tool_action() {
|
||||||
local -r _zaction=${1}
|
local -r _zaction=${1}
|
||||||
_zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
_zimfw_source_zimrc 1 || return 1
|
||||||
|
zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
zimfw() {
|
zimfw() {
|
||||||
builtin emulate -L zsh -o EXTENDED_GLOB
|
builtin emulate -L zsh -o EXTENDED_GLOB
|
||||||
local -r _zversion='<%= version %>' _zversion_target=${ZIM_HOME}/.latest_version zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <action> [<%= bold %>-q<%= normal %>|<%= bold %>-v<%= normal %>]
|
local -r _zversion='<%= 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,12 +46,19 @@ Options:
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
|
local -r _zversion_target=${ZIM_HOME}/.latest_version
|
||||||
|
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)
|
||||||
|
|
|
@ -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.13.0"
|
@version = "1.14.0"
|
||||||
@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,8 +42,4 @@ zim = Zim.new
|
||||||
|
|
||||||
<%= zim.render_commented("LICENSE") %>
|
<%= zim.render_commented("LICENSE") %>
|
||||||
<%= zim.render_all("src/stage2/*.erb") %>
|
<%= zim.render_all("src/stage2/*.erb") %>
|
||||||
if [[ ${functrace[1]} == zmodule:* ]]; then
|
zimfw "${@}"
|
||||||
zmodule "${@}"
|
|
||||||
else
|
|
||||||
zimfw "${@}"
|
|
||||||
fi
|
|
||||||
|
|
71
zimfw.zsh
71
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}$': \E[1mZIM_HOME\E[0;31m 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_FILE=${0}
|
||||||
|
|
||||||
_zimfw_print() {
|
_zimfw_print() {
|
||||||
if (( _zprintlevel > 0 )) print "${@}"
|
if (( _zprintlevel > 0 )) print "${@}"
|
||||||
|
@ -46,7 +50,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} && _zimfw_print -R $'\E[32m)\E[0m \E[1m'${2}$':\E[0m Updated.'${_zrestartmsg}
|
command mv -f ${1} ${2} && command chmod a+r ${2} && _zimfw_print -R $'\E[32m)\E[0m \E[1m'${2}$':\E[0m Updated.'${_zrestartmsg}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +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 'if (( ${+ZIM_HOME} )) zimfw() { source '${${(qqq)__ZIMFW_FILE}/${HOME}/\${HOME}}' "${@}" }'
|
||||||
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})
|
||||||
|
@ -74,7 +77,7 @@ _zimfw_build_init() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
zpre=$'*\0'
|
zpre=$'*\0'
|
||||||
if (( ${#_zfpaths} )) print -R 'fpath=('${(q-)${_zfpaths#${~zpre}}:a}' ${fpath})'
|
if (( ${#_zfpaths} )) print -R 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${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'
|
||||||
|
@ -110,6 +113,7 @@ _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]
|
||||||
|
@ -301,11 +305,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 ${(q-)zarg:a}")
|
zcmds+=('source '${(qqq)zarg:a})
|
||||||
;;
|
;;
|
||||||
-c|--cmd)
|
-c|--cmd)
|
||||||
shift
|
shift
|
||||||
zcmds+=(${1//{}/${(q-)zroot_dir:a}})
|
zcmds+=(${1//{}/${(qqq)zroot_dir:a}})
|
||||||
;;
|
;;
|
||||||
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
|
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
|
||||||
*)
|
*)
|
||||||
|
@ -333,11 +337,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 '${(q-)^prezto_scripts:a})
|
zcmds=('source '${(qqq)^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 '${(q-)^zscripts:a})
|
zcmds=('source '${(qqq)^zscripts:a})
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
||||||
|
@ -347,11 +351,12 @@ 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
|
||||||
|
@ -370,6 +375,9 @@ _zimfw_source_zimrc() {
|
||||||
_zfunctions=(${_zfunctions:#${zpre}*})
|
_zfunctions=(${_zfunctions:#${zpre}*})
|
||||||
_zcmds=(${_zcmds:#${zpre}*})
|
_zcmds=(${_zcmds:#${zpre}*})
|
||||||
done
|
done
|
||||||
|
} always {
|
||||||
|
unfunction zmodule
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_list_unuseds() {
|
_zimfw_list_unuseds() {
|
||||||
|
@ -454,7 +462,7 @@ _zimfw_compile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print -R 'zimfw version: '${_zversion}' (built at 2024-02-17 02:05:06 UTC, previous commit is 9de3984)'
|
print -R 'zimfw version: '${_zversion}' (built at 2024-06-25 17:29:35 UTC, previous commit is 3b7908d)'
|
||||||
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}
|
||||||
|
@ -474,7 +482,11 @@ _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_FILE:A} 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
|
||||||
|
@ -578,7 +590,7 @@ _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 GitHub URL. Will not try to ${_zaction}."
|
_zimfw_print_error ${URL}$' is not a valid URL. Will not try to '${_zaction}$'. The zimfw degit tool only supports GitHub URLs. Use zmodule option \E[1m--use git\E[0;31m to use git instead.'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
|
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
|
||||||
|
@ -586,7 +598,7 @@ _zimfw_download_tarball() {
|
||||||
if [[ -r ${INFO_TARGET} ]]; then
|
if [[ -r ${INFO_TARGET} ]]; then
|
||||||
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
|
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
|
||||||
if [[ ${URL} != ${INFO[1]} ]]; then
|
if [[ ${URL} != ${INFO[1]} ]]; then
|
||||||
_zimfw_print_error "URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
_zimfw_print_error "The zimfw degit URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# Previous REV is in line 2, reserved for future use.
|
# Previous REV is in line 2, reserved for future use.
|
||||||
|
@ -645,10 +657,17 @@ _zimfw_download_tarball() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_untar_tarball() {
|
_zimfw_untar_tarball() {
|
||||||
if ! ERR=$(command tar -C ${1} --strip=1 -xzf ${TARBALL_TARGET} 2>&1); then
|
if ! ERR=$(command tar -C ${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_print_error "Error moving ${zsubdir}" ${ERR}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_tool_degit() {
|
_zimfw_tool_degit() {
|
||||||
|
@ -731,7 +750,7 @@ _zimfw_tool_git() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
|
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}."
|
_zimfw_print_error "The git URL does not match. Expected ${URL}. Will not try to ${_zaction}."
|
||||||
return 1
|
return 1
|
||||||
fi
|
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
|
||||||
|
@ -868,13 +887,14 @@ _zimfw_run_tool() {
|
||||||
|
|
||||||
_zimfw_run_tool_action() {
|
_zimfw_run_tool_action() {
|
||||||
local -r _zaction=${1}
|
local -r _zaction=${1}
|
||||||
_zimfw_source_zimrc 1 && zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
_zimfw_source_zimrc 1 || return 1
|
||||||
|
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.13.0' _zversion_target=${ZIM_HOME}/.latest_version zusage=$'Usage: \E[1m'${0}$'\E[0m <action> [\E[1m-q\E[0m|\E[1m-v\E[0m]
|
local -r _zversion='1.14.0' 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.
|
||||||
|
@ -920,12 +940,19 @@ Options:
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! zstyle -t ':zim' disable-version-check && [[ ${1} != check-version ]]; then
|
local -r _zversion_target=${ZIM_HOME}/.latest_version
|
||||||
|
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,8 +1005,4 @@ Options:
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ${functrace[1]} == zmodule:* ]]; then
|
zimfw "${@}"
|
||||||
zmodule "${@}"
|
|
||||||
else
|
|
||||||
zimfw "${@}"
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue