Compare commits
No commits in common. "master" and "v1.0.1" have entirely different histories.
25
.github/ISSUE_TEMPLATE.md
vendored
Normal file
25
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
Please check the existing issues to make sure you're not duplicating a report.
|
||||||
|
|
||||||
|
For bug reports, please provide the following information:
|
||||||
|
|
||||||
|
In a terminal, run `zimfw info` and paste the output below:
|
||||||
|
|
||||||
|
```
|
||||||
|
#Paste the output here
|
||||||
|
```
|
||||||
|
|
||||||
|
- gist of .zimrc:
|
||||||
|
- gist of .zshrc:
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
|
||||||
|
Steps to reproduce
|
||||||
|
------------------
|
||||||
|
|
||||||
|
|
||||||
|
Images or other information
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
|
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Please follow Zim's [code style guidelines](https://github.com/zimfw/zimfw/wiki/Code-Style-Guide).
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,7 +2,6 @@
|
||||||
*.zwc
|
*.zwc
|
||||||
*.zwc.old
|
*.zwc.old
|
||||||
/modules/
|
/modules/
|
||||||
/.latest_version
|
|
||||||
/init.zsh
|
/init.zsh
|
||||||
/init.zsh.old
|
/init.zsh.old
|
||||||
/login_init.zsh
|
/login_init.zsh
|
||||||
|
|
359
CHANGELOG.md
359
CHANGELOG.md
|
@ -9,339 +9,19 @@ 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
|
|
||||||
|
|
||||||
### 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
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Expansion of prompt sequences in print statements causing text between
|
|
||||||
backticks to be executed by the shell.
|
|
||||||
|
|
||||||
## [1.12.0] - 2023-07-17
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `check-version` action, that immediately checks if a new version of `zimfw` is
|
|
||||||
available and returns code 4 if there is one.
|
|
||||||
- `check` action, that checks if there are updates available for current modules.
|
|
||||||
- Output of `LANG` and `LC_*` parameters in `info` action.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Don't resolve symlinks when building init.zsh.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Show warning when there's no write permission to compile Zsh scripts.
|
|
||||||
|
|
||||||
## [1.11.3] - 2023-02-26
|
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
|
|
||||||
- `check-dumpfile` action. The [completion] module alone now handles
|
|
||||||
checking the dumpfile. (See
|
|
||||||
[zimfw/completion#12](https://github.com/zimfw/completion/pull/12))
|
|
||||||
|
|
||||||
## [1.11.2] - 2023-02-16
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Quote path names in init.zsh to properly handle path names with spaces.
|
|
||||||
|
|
||||||
## [1.11.1] - 2023-02-04
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Use `_zim_dumpfile_fpath` defined by the completion module
|
|
||||||
[here](https://github.com/zimfw/completion/blob/33737e8c15fa8dba9af47bef8408b1af2599c21b/init.zsh#L11),
|
|
||||||
right before `compinit` is run, to more accurately do `zimfw check-dumpfile`.
|
|
||||||
|
|
||||||
## [1.11.0] - 2022-12-18
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `--if` option to `zmodule` that will only initialize the module root if the
|
|
||||||
specified test returns a zero exit status. The test is evaluated at every new
|
|
||||||
terminal startup.
|
|
||||||
- Ability to customize the .zimrc file name and path with the `ZIM_CONFIG_FILE`
|
|
||||||
environment variable.
|
|
||||||
|
|
||||||
## [1.10.0] - 2022-09-27
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `--root` option to `zmodule`. Combined with the ability to call `zmodule`
|
|
||||||
multiple times for the same module, this allows initializing from multiple
|
|
||||||
roots in repositories like prezto or ohmyzsh. Also, `--on-pull` and `--disable`
|
|
||||||
now work on a per-module-root basis.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Show `OSTYPE`, `TERM`, `TERM_PROGRAM` and `TERM_PROGRAM_VERSION` environment
|
|
||||||
variables instead of calling the `uname -a` command to show system info in the
|
|
||||||
`zimfw info` action.
|
|
||||||
|
|
||||||
## [1.9.1] - 2022-05-24
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Override repository options along multiple `zmodule` calls with the same
|
|
||||||
module name.
|
|
||||||
- Show already installed modules skipped with install action and `-v`.
|
|
||||||
- Consider external module directory paths when calling compile action directly.
|
|
||||||
- Ignore return value from `zargs` with `-P`.
|
|
||||||
(See https://www.zsh.org/mla/workers/2022/msg00611.html)
|
|
||||||
|
|
||||||
## [1.9.0] - 2022-05-09
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `--on-pull` option to `zmodule`, which allows setting a command that is always
|
|
||||||
triggered after the module is installed or updated.
|
|
||||||
|
|
||||||
## [1.8.0] - 2022-01-25
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `check-dumpfile` action. It runs in the build, install and update actions, and
|
|
||||||
checks if a new completion configuration needs to be dumped. It's intended to
|
|
||||||
be used with `compinit -C`, so no checks are done during the shell startup.
|
|
||||||
(See [zimfw/completion#8](https://github.com/zimfw/completion/pull/8))
|
|
||||||
- `--no-submodules` option to `zmodule`, which disables installing or updating
|
|
||||||
git submodules.
|
|
||||||
|
|
||||||
## [1.7.0] - 2022-01-12
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- The output of `zimfw init` to be friendlier to the terminal startup screen
|
|
||||||
when called without `-q`.
|
|
||||||
- Only compile scripts via the `zimfw` tool after actions where scripts can
|
|
||||||
change (build, install, update, upgrade).
|
|
||||||
- Move compilation of the completion dumpfile to the completion module,
|
|
||||||
[here](https://github.com/zimfw/completion/blob/9386a76eac3f55b1c04d57d26238f725b4b3ba25/init.zsh#L10-L11).
|
|
||||||
- Don't compile user Zsh startup scripts anymore
|
|
||||||
(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
|
|
||||||
anymore (recommended):
|
|
||||||
```
|
|
||||||
for zfile in ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout); do
|
|
||||||
rm -f ${zfile}.zwc(|.old)(N)
|
|
||||||
done
|
|
||||||
```
|
|
||||||
- or add the following to your .zlogin so Zsh startup scripts continue to be
|
|
||||||
compiled:
|
|
||||||
```diff
|
|
||||||
+for zfile in ${ZDOTDIR:-${HOME}}/.z(shenv|profile|shrc|login|logout); do
|
|
||||||
+ if [[ ! ${zfile}.zwc -nt ${zfile} ]] zcompile -R ${zfile}
|
|
||||||
+done
|
|
||||||
+unset zfile
|
|
||||||
```
|
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
- The login_init.zsh script, which is now empty. This means you can safely
|
|
||||||
remove the following line from your .zlogin:
|
|
||||||
```diff
|
|
||||||
-source ${ZIM_HOME}/login_init.zsh -q &!
|
|
||||||
```
|
|
||||||
|
|
||||||
## [1.6.2] - 2021-11-21
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Force local zsh emulation options, so the code is not broken by unexpected
|
|
||||||
option changes by the user.
|
|
||||||
|
|
||||||
## [1.6.1] - 2021-11-08
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Missing line break before showing git log when using the git tool to update.
|
|
||||||
|
|
||||||
## [1.6.0] - 2021-11-06
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `list` action. Using it with `-v` also shows the current details for all
|
|
||||||
modules.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Be quieter and don't output warnings when `-q` is provided.
|
|
||||||
- Be more verbose when `-v` is provided: show skipped external and frozen
|
|
||||||
modules with the install and update actions.
|
|
||||||
- Show warning instead of error when module was not installed with the tool
|
|
||||||
currently in use.
|
|
||||||
- Manually setting any `zmodule` initialization option will disable all the
|
|
||||||
default values from the other initialization options, so only user-provided
|
|
||||||
values are used in this case. I.e. it's either all automatic, or all manual.
|
|
||||||
- Also install new modules when starting a new shell (via `zimfw init`, that
|
|
||||||
is sourced in .zshrc).
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Error in `zimfw update` with the `git` tool when module directory is under a
|
|
||||||
symlinked directory.
|
|
||||||
- Warning when `WARN_CREATE_GLOBAL` is set and `ZIM_HOME` is not.
|
|
||||||
- "zsh: command not found: zmodule" when trying to run `zmodule` from the shell.
|
|
||||||
Show a more informative error instead.
|
|
||||||
- Don't try to install or update external modules.
|
|
||||||
|
|
||||||
## [1.5.0] - 2021-08-10
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Option to use the new `degit` tool in `zmodule`, that is able to install and
|
|
||||||
update modules from GitHub without requiring `git`. Modules are installed
|
|
||||||
faster and take less disk space when using this tool. It can be set as the
|
|
||||||
default with `zstyle ':zim:zmodule' use 'degit'`.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Force `core.autocrlf=false` when doing `git clone`.
|
|
||||||
(See [#404](https://github.com/zimfw/zimfw/issues/404))
|
|
||||||
- Allow uninstalling modules with custom names that have a slash.
|
|
||||||
|
|
||||||
|
|
||||||
## [1.4.3] - 2021-03-19
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Prefer the prezto module format when using defaults to initialize a module.
|
|
||||||
This is the format we use in our Zim framework modules. It's not well
|
|
||||||
documented anywhere officially, but in short words a prezto module can have:
|
|
||||||
* a `functions` subdirectory that is added to the fpath by the framework,
|
|
||||||
* files inside the `functions` subdirectory that are autoloaded by the
|
|
||||||
framework (except for those with names matching `_*` or `prompt_*_setup`),
|
|
||||||
* an `init.zsh` file that is sourced by the framework.
|
|
||||||
|
|
||||||
## [1.4.2] - 2021-02-19
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- "Not a valid ref: refs/remotes/origin/main" error in `zimfw update`, when the
|
|
||||||
repository's default branch was renamed to main.
|
|
||||||
|
|
||||||
## [1.4.1] - 2021-02-17
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Correctly get the repository's default branch in `zimfw update`. The related
|
|
||||||
change in version 1.4.0 actually broke updating the modules, as new changes
|
|
||||||
stopped being fetched.
|
|
||||||
|
|
||||||
## [1.4.0] - 2021-01-07
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Prompt before uninstalling modules, unless `-q` is set.
|
|
||||||
- Show build date in info.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Show error when no parameter is provided to `-c|--cmd` in `zmodule`.
|
|
||||||
- Use repository's default branch instead of hardcoding the default to `master`
|
|
||||||
in `zimfw update`, when no branch is specified in `zmodule`.
|
|
||||||
|
|
||||||
## [1.3.2] - 2020-08-01
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Compiled files must also be cleaned from modules defined with absolute paths.
|
|
||||||
|
|
||||||
## [1.3.1] - 2020-07-24
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- "gzip: stdin: unexpected end of file" error when trying to upgrade.
|
|
||||||
(See [#407](https://github.com/zimfw/zimfw/issues/407))
|
|
||||||
|
|
||||||
## [1.3.0] - 2020-07-05
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `-c|-cmd` option to `zmodule`. This allows for executing any specified command.
|
|
||||||
|
|
||||||
## [1.2.2] - 2020-06-10
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Allow local modules to be initialized and compiled in their respective
|
|
||||||
directories, when absolute paths are given, instead of forcing them to be
|
|
||||||
installed inside `ZIM_HOME`.
|
|
||||||
|
|
||||||
## [1.2.1] - 2020-05-26
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- "No such file or directory" error when building a new file. This was a
|
|
||||||
regression introduced after replacing `cmp` by `cksum` in version 1.2.0.
|
|
||||||
- Show warning message when nothing found to be initialized in a module.
|
|
||||||
|
|
||||||
## [1.2.0] - 2020-05-17
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Use `cksum` instead of `cmp`, and `zargs` instead of `xargs`, so we don't
|
|
||||||
depend on busybox or diffutils and findutils.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Error messages and the `zmodule` usage text.
|
|
||||||
|
|
||||||
## [1.1.1] - 2020-01-26
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- "no such file or directory" error before initial check for latest version.
|
|
||||||
- Show error when no modules defined in .zimrc, instead of allowing xargs to
|
|
||||||
execute the action with no positional parameters.
|
|
||||||
|
|
||||||
## [1.1.0] - 2020-01-20
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `help` and `version` actions.
|
|
||||||
- `-v` verbose option. Normal mode output is now focused on the specified action.
|
|
||||||
- Asynchronously check the latest version every 30 days. This can be disabled
|
|
||||||
with `zstyle ':zim' disable-version-check yes`.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- When upgrading, download latest release asset instead of raw file from the
|
|
||||||
master branch.
|
|
||||||
- `curl` is preferred over `wget`.
|
|
||||||
(See [#360](https://github.com/zimfw/zimfw/issues/360))
|
|
||||||
- `wget`'s output is only shown in verbose mode.
|
|
||||||
|
|
||||||
## [1.0.1] - 2020-01-09
|
## [1.0.1] - 2020-01-09
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Zsh 5.2 does not recognize the `:P` modifier. Replace it by `:A`.
|
- Zsh 5.2 does not recognize the `:P` modifier. Replace it by `:A`.
|
||||||
- Also compile and clean .zprofile among the startup files.
|
- Also compile and clean .zprofile among the startup files.
|
||||||
- Don't fail on `clean-dumpfile` when there's nothing to remove.
|
- Don't fail on `zimfw clean-dumpfile` when there's nothing to remove.
|
||||||
|
|
||||||
## [1.0.0] - 2020-01-07
|
## [1.0.0] - 2020-01-07
|
||||||
|
|
||||||
This is a major change, where modules are not git submodules in the Zim repo
|
This is a major change, where modules are not git submodules in the Zim repo
|
||||||
anymore, but customized and installed separately as individual repositories.
|
anymore, but customized and installed separately as individual repositories.
|
||||||
External modules can more easily be installed, updated and uninstalled. This
|
External modules can more easily be installed, updated and uninstalled. This
|
||||||
makes Zim a project for Zsh that is both a set of community-maintained
|
makes Zim the first project for Zsh that is both a set of community-maintained
|
||||||
modules with a default installation (like on-my-zsh and prezto) and a plugin
|
modules with a default installation (like on-my-zsh and prezto) and a plugin
|
||||||
manager (like antigen and zplug).
|
manager (like antigen and zplug).
|
||||||
|
|
||||||
|
@ -360,7 +40,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
|
||||||
|
@ -391,7 +71,6 @@ Take your time to review the updated [README.md] and the changes listed below.
|
||||||
- `ZIM_HOME` is set in .zshenv instead of .zshrc. The issue was that the
|
- `ZIM_HOME` is set in .zshenv instead of .zshrc. The issue was that the
|
||||||
variable was not available in .zlogin in non-interactive login shells.
|
variable was not available in .zlogin in non-interactive login shells.
|
||||||
|
|
||||||
[completion]: https://github.com/zimfw/completion
|
|
||||||
[README.md]: https://github.com/zimfw/zimfw/blob/master/README.md
|
[README.md]: https://github.com/zimfw/zimfw/blob/master/README.md
|
||||||
[environment]: https://github.com/zimfw/environment
|
[environment]: https://github.com/zimfw/environment
|
||||||
[input]: https://github.com/zimfw/input
|
[input]: https://github.com/zimfw/input
|
||||||
|
@ -399,36 +78,6 @@ 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.0.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.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.2]: https://github.com/zimfw/zimfw/compare/v1.11.1...v1.11.2
|
|
||||||
[1.11.1]: https://github.com/zimfw/zimfw/compare/v1.11.0...v1.11.1
|
|
||||||
[1.11.0]: https://github.com/zimfw/zimfw/compare/v1.10.0...v1.11.0
|
|
||||||
[1.10.0]: https://github.com/zimfw/zimfw/compare/v1.9.1...v1.10.0
|
|
||||||
[1.9.1]: https://github.com/zimfw/zimfw/compare/v1.9.0...v1.9.1
|
|
||||||
[1.9.0]: https://github.com/zimfw/zimfw/compare/v1.8.0...v1.9.0
|
|
||||||
[1.8.0]: https://github.com/zimfw/zimfw/compare/v1.7.0...v1.8.0
|
|
||||||
[1.7.0]: https://github.com/zimfw/zimfw/compare/v1.6.2...v1.7.0
|
|
||||||
[1.6.2]: https://github.com/zimfw/zimfw/compare/v1.6.1...v1.6.2
|
|
||||||
[1.6.1]: https://github.com/zimfw/zimfw/compare/v1.6.0...v1.6.1
|
|
||||||
[1.6.0]: https://github.com/zimfw/zimfw/compare/v1.5.0...v1.6.0
|
|
||||||
[1.5.0]: https://github.com/zimfw/zimfw/compare/v1.4.3...v1.5.0
|
|
||||||
[1.4.3]: https://github.com/zimfw/zimfw/compare/v1.4.2...v1.4.3
|
|
||||||
[1.4.2]: https://github.com/zimfw/zimfw/compare/v1.4.1...v1.4.2
|
|
||||||
[1.4.1]: https://github.com/zimfw/zimfw/compare/v1.4.0...v1.4.1
|
|
||||||
[1.4.0]: https://github.com/zimfw/zimfw/compare/v1.3.2...v1.4.0
|
|
||||||
[1.3.2]: https://github.com/zimfw/zimfw/compare/v1.3.1...v1.3.2
|
|
||||||
[1.3.1]: https://github.com/zimfw/zimfw/compare/v1.3.0...v1.3.1
|
|
||||||
[1.3.0]: https://github.com/zimfw/zimfw/compare/v1.2.2...v1.3.0
|
|
||||||
[1.2.2]: https://github.com/zimfw/zimfw/compare/v1.2.1...v1.2.2
|
|
||||||
[1.2.1]: https://github.com/zimfw/zimfw/compare/v1.2.0...v1.2.1
|
|
||||||
[1.2.0]: https://github.com/zimfw/zimfw/compare/v1.1.1...v1.2.0
|
|
||||||
[1.1.1]: https://github.com/zimfw/zimfw/compare/v1.1.0...v1.1.1
|
|
||||||
[1.1.0]: https://github.com/zimfw/zimfw/compare/v1.0.1...v1.1.0
|
|
||||||
[1.0.1]: https://github.com/zimfw/zimfw/compare/v1.0.0...v1.0.1
|
[1.0.1]: https://github.com/zimfw/zimfw/compare/v1.0.0...v1.0.1
|
||||||
[1.0.0]: https://github.com/zimfw/zimfw/compare/5d66578...v1.0.0
|
[1.0.0]: https://github.com/zimfw/zimfw/compare/5d66578...v1.0.0
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -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-2020 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
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
srcfiles := src/zimfw.zsh.erb $(wildcard src/*/*.erb) LICENSE
|
srcfiles := src/zimfw.zsh.erb $(wildcard src/*/*.erb)
|
||||||
|
|
||||||
zimfw.zsh: $(srcfiles)
|
zimfw.zsh: $(srcfiles)
|
||||||
erb $< >| $@
|
erb $< >| $@
|
||||||
|
|
398
README.md
398
README.md
|
@ -1,372 +1,144 @@
|
||||||
<p align="center">
|
Zsh IMproved FrameWork
|
||||||
<a href="https://github.com/zimfw/zimfw/releases"><img src="https://img.shields.io/github/v/release/zimfw/zimfw"></a>
|
======================
|
||||||
<a href="https://github.com/zimfw/zimfw/issues"><img src="https://img.shields.io/github/issues/zimfw/zimfw.svg"></a>
|
|
||||||
<a href="https://github.com/zimfw/zimfw/network/members"><img src="https://img.shields.io/github/forks/zimfw/zimfw.svg"></a>
|
|
||||||
<a href="https://github.com/zimfw/zimfw/stargazers"><img src="https://img.shields.io/github/stars/zimfw/zimfw.svg"></a>
|
|
||||||
<a href="https://github.com/zimfw/zimfw/releases"><img src="https://img.shields.io/github/downloads/zimfw/zimfw/total.svg"></a>
|
|
||||||
<a href="https://github.com/zimfw/zimfw/discussions"><img src="https://img.shields.io/badge/forum-online-green.svg"></a>
|
|
||||||
<a href="https://github.com/zimfw/zimfw/blob/master/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/zimfw/zimfw"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="https://github.com/zimfw/zimfw">
|
<a href="https://github.com/zimfw/zimfw">
|
||||||
<img width="600" src="https://zimfw.github.io/images/zimfw-banner@2.jpg">
|
<img width="650" src="https://zimfw.github.io/images/zim_banner.png">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
What is Zim?
|
What is Zim?
|
||||||
------------
|
------------
|
||||||
Zim is a Zsh configuration framework that bundles a [plugin manager](#usage),
|
Zim is a Zsh configuration framework with [blazing speed] and modular extensions.
|
||||||
useful [modules] and a wide variety of [themes], without compromising on [speed].
|
|
||||||
|
|
||||||
Check how Zim compares to other frameworks and plugin managers:
|
Zim is very easy to customize, and comes with a rich set of modules and features without compromising on speed or functionality!
|
||||||
|
|
||||||
<a href="https://github.com/zimfw/zimfw/wiki/Speed">
|
What does Zim offer?
|
||||||
<img src="https://zimfw.github.io/images/results.svg">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
Table of Contents
|
|
||||||
-----------------
|
-----------------
|
||||||
* [Installation](#installation)
|
If you're here, it means you want to see the cool shit Zim can do. Check out the [available modules]!
|
||||||
* [Automatic installation](#automatic-installation)
|
|
||||||
* [Manual installation](#manual-installation)
|
Below is a brief showcase of Zim's features.
|
||||||
* [Set up `~/.zshrc`](#set-up-zshrc)
|
|
||||||
* [Create `~/.zimrc`](#create-zimrc)
|
### Speed
|
||||||
* [Usage](#usage)
|
For a speed comparison between Zim and other frameworks, see [this wiki entry][blazing speed].
|
||||||
* [`zmodule`](#zmodule)
|
|
||||||
* [`zimfw`](#zimfw)
|
### Themes
|
||||||
* [Settings](#settings)
|
|
||||||
* [Uninstalling](#uninstalling)
|
To preview some of the available themes, check the [themes wiki page].
|
||||||
|
|
||||||
|
### Fish-shell history navigation
|
||||||
|
![history-substring-search]
|
||||||
|
|
||||||
|
### Syntax highlighting
|
||||||
|
![syntax-highlighting]
|
||||||
|
|
||||||
|
### And much more!
|
||||||
|
Zim has many modules! Enable as many or as few as you'd like.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
Installing Zim is easy. You can choose either the automatic or manual method below:
|
Installing Zim is easy:
|
||||||
|
|
||||||
### Automatic installation
|
* With curl:
|
||||||
|
|
||||||
This will install a predefined set of modules and a theme for you.
|
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
|
||||||
|
|
||||||
* With `curl`:
|
* With wget:
|
||||||
```zsh
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
|
|
||||||
```
|
|
||||||
|
|
||||||
* With `wget`:
|
wget -nv -O - https://raw.githubusercontent.com/zimfw/install/master/install.zsh | 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
|
Open a new terminal and you're done! Enjoy your Zsh IMproved! Take some time to
|
||||||
to tweak your [`~/.zshrc`](#set-up-zshrc) file and to also check the available
|
read about the [available modules] and tweak your `.zshrc` file.
|
||||||
[modules] and [themes] you can add to your [`~/.zimrc`](#create-zimrc).
|
|
||||||
|
If you have a different shell framework installed (like oh-my-zsh or prezto),
|
||||||
|
*uninstall those first to prevent conflicts*.
|
||||||
|
|
||||||
### Manual installation
|
### Manual installation
|
||||||
|
|
||||||
1. Set Zsh as the default shell, if you haven't done so already:
|
1. Start a Zsh shell
|
||||||
```zsh
|
|
||||||
chsh -s $(which zsh)
|
|
||||||
````
|
|
||||||
|
|
||||||
2. [Set up your `~/.zshrc` file](#set-up-zshrc)
|
zsh
|
||||||
|
|
||||||
3. [Create your `~/.zimrc` file](#create-zimrc)
|
2. Set Zsh as the default shell:
|
||||||
|
|
||||||
4. Restart your terminal and you're done. Enjoy your Zsh IMproved!
|
chsh -s =zsh
|
||||||
|
|
||||||
#### Set up `~/.zshrc`
|
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/master/zimfw.zsh to
|
||||||
|
`~/.zim/zimfw.zsh`.
|
||||||
|
|
||||||
Add the lines below to your `~/.zshrc` file, in the following order:
|
4. Add the lines in the following templates to the respective dot files:
|
||||||
|
* [~/.zshenv](https://github.com/zimfw/install/blob/master/src/templates/zshenv)
|
||||||
|
* [~/.zshrc](https://github.com/zimfw/install/blob/master/src/templates/zshrc)
|
||||||
|
* [~/.zlogin](https://github.com/zimfw/install/blob/master/src/templates/zlogin)
|
||||||
|
* [~/.zimrc](https://github.com/zimfw/install/blob/master/src/templates/zimrc)
|
||||||
|
|
||||||
1. To use our `degit` tool by default to install modules:
|
5. Install the modules defined in `~/.zimrc` and build the initialization scripts:
|
||||||
```zsh
|
|
||||||
zstyle ':zim:zmodule' use 'degit'
|
|
||||||
````
|
|
||||||
This is optional and only required if you don't have `git` installed (yes,
|
|
||||||
zimfw works even without `git`!)
|
|
||||||
|
|
||||||
2. To set where the zimfw plugin manager configuration file will be located:
|
source ~/.zim/zimfw.zsh install
|
||||||
```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
|
|
||||||
ZIM_HOME=~/.zim
|
|
||||||
```
|
|
||||||
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
|
|
||||||
`~/.cache/zim`.
|
|
||||||
|
|
||||||
4. To automatically download the zimfw plugin manager if missing:
|
|
||||||
```zsh
|
|
||||||
# Download zimfw plugin manager if missing.
|
|
||||||
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
|
||||||
curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
|
|
||||||
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
Or if you use `wget` instead of `curl`:
|
|
||||||
```zsh
|
|
||||||
# Download zimfw plugin manager if missing.
|
|
||||||
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
|
||||||
mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \
|
|
||||||
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
This is optional. Alternatively, you can download the `zimfw.zsh` script
|
|
||||||
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.
|
|
||||||
|
|
||||||
5. To automatically install missing modules and update the static initialization
|
|
||||||
script if missing or outdated:
|
|
||||||
```zsh
|
|
||||||
# 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
|
|
||||||
source ${ZIM_HOME}/zimfw.zsh init -q
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
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
|
|
||||||
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.
|
|
||||||
|
|
||||||
6. To source the static script, that will initialize your modules:
|
|
||||||
```zsh
|
|
||||||
# Initialize modules.
|
|
||||||
source ${ZIM_HOME}/init.zsh
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Create `~/.zimrc`
|
|
||||||
|
|
||||||
This file configures the zimfw plugin manager. It's referred to as `~/.zimrc`
|
|
||||||
in the documentation for the sake of simplicity, but the actual location of the
|
|
||||||
file is defined by the following rules:
|
|
||||||
|
|
||||||
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
|
|
||||||
zmodule zsh-users/zsh-syntax-highlighting
|
|
||||||
zmodule zsh-users/zsh-autosuggestions
|
|
||||||
```
|
|
||||||
|
|
||||||
If you also want one of our prompt [themes]:
|
|
||||||
```zsh
|
|
||||||
zmodule git-info
|
|
||||||
zmodule duration-info
|
|
||||||
zmodule asciiship
|
|
||||||
zmodule zsh-users/zsh-syntax-highlighting
|
|
||||||
zmodule zsh-users/zsh-autosuggestions
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to use our [completion] module too, instead of using `compinit` directly:
|
|
||||||
```zsh
|
|
||||||
zmodule git-info
|
|
||||||
zmodule duration-info
|
|
||||||
zmodule asciiship
|
|
||||||
zmodule zsh-users/zsh-completions --fpath src
|
|
||||||
zmodule completion
|
|
||||||
zmodule zsh-users/zsh-syntax-highlighting
|
|
||||||
zmodule zsh-users/zsh-autosuggestions
|
|
||||||
```
|
|
||||||
The [completion] module calls `compinit` for you. You should remove any
|
|
||||||
`compinit` calls from your `~/.zshrc` when you use this module. The modules will
|
|
||||||
be initialized in the order they are defined, and [completion] must be
|
|
||||||
initialized *after* all modules that add completion definitions, so it must come
|
|
||||||
after [zsh-users/zsh-completions].
|
|
||||||
|
|
||||||
Check the [`zmodule` usage](#zmodule) below for more examples on how to use it to
|
|
||||||
define the modules you want to use.
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
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
|
|
||||||
modules are defined in your `~/.zimrc` file.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
The `~/.zimrc` file is not sourced during Zsh startup and it's only used to
|
|
||||||
configure the zimfw plugin manager.
|
|
||||||
|
|
||||||
Check [examples of `~/.zimrc` files](#create-zimrc) above.
|
|
||||||
|
|
||||||
### zmodule
|
### zmodule
|
||||||
|
|
||||||
Below are some usage examples:
|
Add `zmodule` calls to your `~/.zimrc` file to define the modules to be initialized.
|
||||||
|
The modules are initialized in the same order they are defined. Add:
|
||||||
|
|
||||||
* A module from the [@zimfw] organization: `zmodule archive`
|
zmodule <url> [-n|--name <module_name>] [options]
|
||||||
* A module from another GitHub organization: `zmodule StackExchange/blackbox`
|
|
||||||
* A module with a custom URL: `zmodule https://gitlab.com/Spriithy/basher.git`
|
|
||||||
* A module at an absolute path, that is already installed:
|
|
||||||
`zmodule /usr/local/share/zsh-autosuggestions`
|
|
||||||
* 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:
|
|
||||||
`zmodule spaceship-prompt/spaceship-prompt --source spaceship.zsh --no-submodules` or
|
|
||||||
`zmodule spaceship-prompt/spaceship-prompt --name spaceship --no-submodules`
|
|
||||||
* A module with two custom initialization files:
|
|
||||||
`zmodule sindresorhus/pure --source async.zsh --source pure.zsh`. Separate
|
|
||||||
zmodule calls can also be used. In this equivalent example, the second call
|
|
||||||
automatically discovers the second file to be sourced:
|
|
||||||
```
|
|
||||||
zmodule sindresorhus/pure --source async.zsh
|
|
||||||
zmodule sindresorhus/pure
|
|
||||||
```
|
|
||||||
* A module with a custom initialization command:
|
|
||||||
`zmodule skywind3000/z.lua --cmd 'eval "$(lua {}/z.lua --init zsh enhanced once)"'`
|
|
||||||
* A module with an on-pull command. It can be used to create a cached initialization script:
|
|
||||||
`zmodule skywind3000/z.lua --on-pull 'lua z.lua --init zsh enhanced once >! init.zsh'`
|
|
||||||
* A module with a big git repository: `zmodule romkatv/powerlevel10k --use degit`
|
|
||||||
* A module with a custom root subdirectory: `zmodule ohmyzsh/ohmyzsh --root plugins/vim-interaction`
|
|
||||||
* A module with multiple roots:
|
|
||||||
```
|
|
||||||
zmodule sorin-ionescu/prezto --root modules/command-not-found
|
|
||||||
zmodule sorin-ionescu/prezto --root modules/gnu-utility
|
|
||||||
```
|
|
||||||
or
|
|
||||||
```
|
|
||||||
zmodule ohmyzsh/ohmyzsh --root plugins/perl
|
|
||||||
zmodule ohmyzsh/ohmyzsh --root plugins/vim-interaction
|
|
||||||
```
|
|
||||||
|
|
||||||
<details id="zmodule-usage">
|
where `<url>` is the required repository URL or path. The following formats
|
||||||
<summary>Want help with the complete <code>zmodule</code> usage?</summary>
|
are equivalent: `name`, `zimfw/name`, `https://github.com/zimfw/name.git`.
|
||||||
|
|
||||||
<pre>Usage: <b>zmodule</b> <url> [<b>-n</b>|<b>--name</b> <module_name>] [<b>-r</b>|<b>--root</b> <path>] [options]
|
By default, the module name is the last component in the `<url>`. Use the
|
||||||
|
`-n|--name <module_name>` option to set a custom module name.
|
||||||
|
|
||||||
Add <b>zmodule</b> calls to your <b>~/.zimrc</b> file to define the modules to be initialized. The initiali-
|
#### Repository options
|
||||||
zation will be done in the same order it's defined.
|
|
||||||
|
|
||||||
<url> Module absolute path or repository URL. The following URL formats
|
* `-b|--branch <branch_name>`: Use specified branch when installing and
|
||||||
are equivalent: <b>foo</b>, <b>zimfw/foo</b>, <b>https://github.com/zimfw/foo.git</b>.
|
updating the module. Overrides the tag option. Default: `master`.
|
||||||
If an absolute path is given, the module is considered externally
|
* `-t|--tag <tag_name>`: Use specified tag when installing and updating the
|
||||||
installed and won't be installed or updated by zimfw.
|
module. Overrides the branch option.
|
||||||
<b>-n</b>|<b>--name</b> <module_name> Set a custom module name. Default: the last component in <url>.
|
* `-z|--frozen`: Don't install or update the module.
|
||||||
Slashes can be used inside the name to organize the module into
|
|
||||||
subdirectories. The module will be installed at
|
|
||||||
<b>${ZIM_HOME}/</b><module_name>.
|
|
||||||
<b>-r</b>|<b>--root</b> <path> Relative path to the module root.
|
|
||||||
|
|
||||||
Per-module options:
|
#### Initialization options
|
||||||
<b>-b</b>|<b>--branch</b> <branch_name> Use specified branch when installing and updating the module.
|
|
||||||
Overrides the tag option. Default: the repository default branch.
|
|
||||||
<b>-t</b>|<b>--tag</b> <tag_name> Use specified tag when installing and updating the module. Over-
|
|
||||||
rides the branch option.
|
|
||||||
<b>-u</b>|<b>--use</b> <tool_name> Install and update the module using the defined tool. Default is
|
|
||||||
either defined by <b>zstyle ':zim:zmodule' use '</b><tool_name><b>'</b>, or <b>git</b>
|
|
||||||
if none is provided. The tools available are:
|
|
||||||
<b>git</b> uses the git command. Local changes are preserved on updates.
|
|
||||||
<b>degit</b> uses curl or wget, and currently only works with GitHub
|
|
||||||
URLs. Modules install faster and take less disk space. Local
|
|
||||||
changes are lost on updates. Git submodules are not supported.
|
|
||||||
<b>mkdir</b> creates an empty directory. The <url> 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't install or update git submodules.
|
|
||||||
<b>-z</b>|<b>--frozen</b> Don't install or update the module.
|
|
||||||
|
|
||||||
The per-module options above are carried over multiple zmodule calls for the same module.
|
* `-f|--fpath <path>`: Add specified path to `fpath`. The path is relative to
|
||||||
Modules are uniquely identified by their name.
|
the module root directory. Default: `functions`, if the subdirectory exists.
|
||||||
|
* `-a|--autoload <function_name>`: Autoload specified function. Default: all
|
||||||
Per-module-root options:
|
valid names inside the module's specified `fpath` paths.
|
||||||
<b>--if</b> <test> Will only initialize module root if specified test returns a zero
|
* `-s|--source <file_path>`: Source specified file. The file path is relative
|
||||||
exit status. The test is evaluated at every new terminal startup.
|
to the module root directory. Default: the file with largest size matching
|
||||||
<b>--if-command</b> <cmd_name> Will only initialize module root if specified external command is
|
`{init.zsh|module_name.{zsh|plugin.zsh|zsh-theme|sh}}`, if any exists.
|
||||||
available. This is evaluated at every new terminal startup.
|
* `-d|--disabled`: Don't use or uninstall the module.
|
||||||
Equivalent to <b>--if '(( ${+commands[</b><cmd_name><b>]} ))'</b>.
|
|
||||||
<b>--on-pull</b> <command> Execute command after installing or updating the module. The com-
|
|
||||||
mand is executed in the module root directory.
|
|
||||||
<b>-d</b>|<b>--disabled</b> Don't initialize the module root or uninstall the module.
|
|
||||||
|
|
||||||
The per-module-root options above are carried over multiple zmodule calls for the same mod-
|
|
||||||
ule root.
|
|
||||||
|
|
||||||
Per-call initialization options:
|
|
||||||
<b>-f</b>|<b>--fpath</b> <path> Will add specified path to fpath. The path is relative to the
|
|
||||||
module root directory. Default: <b>functions</b>, if the subdirectory
|
|
||||||
exists and is non-empty.
|
|
||||||
<b>-a</b>|<b>--autoload</b> <func_name> Will autoload specified function. Default: all valid names inside
|
|
||||||
the <b>functions</b> subdirectory, if any.
|
|
||||||
<b>-s</b>|<b>--source</b> <file_path> Will source specified file. The path is relative to the module
|
|
||||||
root directory. Default: <b>init.zsh</b>, if a non-empty <b>functions</b> sub-
|
|
||||||
directory exists, else the largest of the files matching the glob
|
|
||||||
<b>(init.zsh|</b><name><b>.(zsh|plugin.zsh|zsh-theme|sh))</b>, if any.
|
|
||||||
<name> in the glob is resolved to the last component of the mod-
|
|
||||||
ule name, or the last component of the path to the module root.
|
|
||||||
<b>-c</b>|<b>--cmd</b> <command> Will execute specified command. Occurrences of the <b>{}</b> placeholder
|
|
||||||
in the command are substituted by the module root directory path.
|
|
||||||
I.e., <b>-s 'foo.zsh'</b> and <b>-c 'source {}/foo.zsh'</b> are equivalent.
|
|
||||||
|
|
||||||
Setting any per-call initialization option above will disable the default values from the
|
|
||||||
other per-call initialization options, so only your provided values will be used. I.e. these
|
|
||||||
values are either all automatic, or all manual in each zmodule call. To use default values
|
|
||||||
and also provided values, use separate zmodule calls.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### zimfw
|
### zimfw
|
||||||
|
|
||||||
The Zim plugin manager:
|
Added new modules to `~/.zimrc`? Run:
|
||||||
|
|
||||||
* Added new modules to `~/.zimrc`? Run `zimfw install`.
|
zimfw install
|
||||||
* Removed modules from `~/.zimrc`? Run `zimfw uninstall`.
|
|
||||||
* Want to update your modules to their latest revisions? Run `zimfw update`.
|
|
||||||
* Want to upgrade zimfw to its latest version? Run `zimfw upgrade`.
|
|
||||||
* For more information about the zimfw plugin manager, run `zimfw help`.
|
|
||||||
|
|
||||||
Settings
|
Removed modules from `~/.zimrc`? Run:
|
||||||
--------
|
|
||||||
Set the path of the directory used by zimfw with the `ZIM_HOME` environment
|
|
||||||
variable:
|
|
||||||
|
|
||||||
ZIM_HOME=~/.zim
|
zimfw uninstall
|
||||||
|
|
||||||
By default, the zimfw plugin manager configuration file must be at `~/.zimrc`,
|
Want to update your modules to their latest revisions? Run:
|
||||||
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
|
|
||||||
`ZIM_CONFIG_FILE` environment variable:
|
|
||||||
|
|
||||||
ZIM_CONFIG_FILE=~/.config/zsh/zimrc
|
zimfw update
|
||||||
|
|
||||||
Modules are installed using `git` by default. If you don't have `git`
|
Want to upgrade `~/.zim/zimfw.zsh` to the latest version? Run:
|
||||||
installed, or if you want to take advantage of our degit tool for faster and
|
|
||||||
lighter module installations, you can set degit as the default tool with:
|
|
||||||
|
|
||||||
zstyle ':zim:zmodule' use 'degit'
|
zimfw upgrade
|
||||||
|
|
||||||
By default, zimfw will check if it has a new version available every 30 days. If
|
For more information about the `zimfw` tool, run `zimfw` with no parameters.
|
||||||
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
|
|
||||||
|
|
||||||
Uninstalling
|
Uninstalling
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
||||||
remove the initialization lines from your `~/.zshenv`, `~/.zshrc` and `~/.zlogin`.
|
remove the initialization lines from your `~/.zshenv`, `~/.zshrc` and `~/.zlogin`.
|
||||||
|
|
||||||
[modules]: https://zimfw.sh/docs/modules/
|
[history-substring-search]: https://zimfw.github.io/images/zim_history-substring-search.gif
|
||||||
[themes]: https://zimfw.sh/docs/themes/
|
[syntax-highlighting]: https://zimfw.github.io/images/zim_syntax-highlighting.gif
|
||||||
[speed]: https://github.com/zimfw/zimfw/wiki/Speed
|
[blazing speed]: https://github.com/zimfw/zimfw/wiki/Speed
|
||||||
[@zimfw]: https://github.com/zimfw
|
[available modules]: https://github.com/zimfw/zimfw/wiki/Modules
|
||||||
[completion]: https://github.com/zimfw/completion
|
[themes wiki page]: https://github.com/zimfw/zimfw/wiki/Themes
|
||||||
[zsh-users/zsh-completions]: https://github.com/zsh-users/zsh-completions
|
|
||||||
|
|
|
@ -1,241 +0,0 @@
|
||||||
zmodule() {
|
|
||||||
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}
|
|
||||||
local -r zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <url> [<%= bold %>-n<%= normal %>|<%= bold %>--name<%= normal %> <module_name>] [<%= bold %>-r<%= normal %>|<%= bold %>--root<%= normal %> <path>] [options]
|
|
||||||
|
|
||||||
Add <%= bold %>zmodule<%= normal %> calls to your <%= bold %>'${ztarget}$'<%= normal %> file to define the modules to be initialized.
|
|
||||||
The initialization will be done in the same order it\'s defined.
|
|
||||||
|
|
||||||
<url> Module absolute path or repository URL. The following URL formats
|
|
||||||
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
|
|
||||||
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>.
|
|
||||||
Slashes can be used inside the name to organize the module into
|
|
||||||
subdirectories. The module will be installed at
|
|
||||||
<%= bold %>'${ZIM_HOME}$'/<%= normal %><module_name>.
|
|
||||||
<%= bold %>-r<%= normal %>|<%= bold %>--root<%= normal %> <path> Relative path to the module root.
|
|
||||||
|
|
||||||
Per-module options:
|
|
||||||
<%= bold %>-b<%= normal %>|<%= bold %>--branch<%= normal %> <branch_name> Use specified branch when installing and updating the module.
|
|
||||||
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-
|
|
||||||
rides the branch option.
|
|
||||||
<%= bold %>-u<%= normal %>|<%= bold %>--use<%= normal %> <tool_name> 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 %>
|
|
||||||
if none is provided. The tools available are:
|
|
||||||
<%= bold %>git<%= normal %> uses the git command. Local changes are preserved on updates.
|
|
||||||
<%= bold %>degit<%= normal %> uses curl or wget, and currently only works with GitHub
|
|
||||||
URLs. Modules install faster and take less disk space. Local
|
|
||||||
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 %>-z<%= normal %>|<%= bold %>--frozen<%= normal %> Don\'t install or update the module.
|
|
||||||
|
|
||||||
The per-module options above are carried over multiple zmodule calls for the same module.
|
|
||||||
Modules are uniquely identified by their name.
|
|
||||||
|
|
||||||
Per-module-root options:
|
|
||||||
<%= 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.
|
|
||||||
<%= 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-
|
|
||||||
mand is executed in the module root directory.
|
|
||||||
<%= bold %>-d<%= normal %>|<%= bold %>--disabled<%= normal %> Don\'t initialize the module root or uninstall the module.
|
|
||||||
|
|
||||||
The per-module-root options above are carried over multiple zmodule calls for the same mod-
|
|
||||||
ule root.
|
|
||||||
|
|
||||||
Per-call initialization options:
|
|
||||||
<%= bold %>-f<%= normal %>|<%= bold %>--fpath<%= normal %> <path> Will add specified path to fpath. The path is relative to the
|
|
||||||
module root directory. Default: <%= bold %>functions<%= normal %>, if the subdirectory
|
|
||||||
exists and is non-empty.
|
|
||||||
<%= bold %>-a<%= normal %>|<%= bold %>--autoload<%= normal %> <func_name> Will autoload specified function. Default: all valid names inside
|
|
||||||
the <%= bold %>functions<%= normal %> subdirectory, if any.
|
|
||||||
<%= bold %>-s<%= normal %>|<%= bold %>--source<%= normal %> <file_path> Will source specified file. The path is relative to the module
|
|
||||||
root directory. Default: <%= bold %>init.zsh<%= normal %>, if a non-empty <%= bold %>functions<%= normal %> sub-
|
|
||||||
directory exists, else the largest of the files matching the glob
|
|
||||||
<%= bold %>(init.zsh|<%= normal %><name><%= bold %>.(zsh|plugin.zsh|zsh-theme|sh))<%= normal %>, if any.
|
|
||||||
<name> in the glob is resolved to the last component of the mod-
|
|
||||||
ule name, or the last component of the path to the module root.
|
|
||||||
<%= bold %>-c<%= normal %>|<%= bold %>--cmd<%= normal %> <command> Will execute specified command. Occurrences of the <%= bold %>{}<%= normal %> placeholder
|
|
||||||
in the command are substituted by the module root directory path.
|
|
||||||
I.e., <%= bold %>-s \'foo.zsh\'<%= normal %> and <%= bold %>-c \'source {}/foo.zsh\'<%= normal %> are equivalent.
|
|
||||||
|
|
||||||
Setting any per-call initialization option above will disable the default values from the
|
|
||||||
other per-call initialization options, so only your provided values will be used. I.e. these
|
|
||||||
values are either all automatic, or all manual in each zmodule call. To use default values
|
|
||||||
and also provided values, use separate zmodule calls.'
|
|
||||||
if [[ ${${funcfiletrace[1]%:*}:A} != ${ztarget:A} ]]; then
|
|
||||||
print -u2 -lR $'<%= red %>'${0}$': Must be called from <%= bold %>'${ztarget}$'<%= normal %>' '' ${zusage}
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
if (( ! # )); then
|
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$': Missing zmodule url<%= normal %>' '' ${zusage}
|
|
||||||
_zfailed=1
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
local zurl=${1} zname=${1:t} zroot zarg
|
|
||||||
local -a zfpaths zfunctions zcmds
|
|
||||||
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
|
||||||
zname=${zname%.git}
|
|
||||||
elif [[ ${zurl} != /* ]]; then
|
|
||||||
# Count number of slashes
|
|
||||||
case ${#zurl//[^\/]/} in
|
|
||||||
0) zurl=https://github.com/zimfw/${zurl}.git ;;
|
|
||||||
1) zurl=https://github.com/${zurl}.git ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
while [[ ${1} == (-n|--name|-r|--root) ]]; do
|
|
||||||
if (( # < 2 )); then
|
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
|
|
||||||
_zfailed=1
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
case ${1} in
|
|
||||||
-n|--name)
|
|
||||||
shift
|
|
||||||
zname=${${1%%/##}##/##}
|
|
||||||
;;
|
|
||||||
-r|--root)
|
|
||||||
shift
|
|
||||||
zroot=${${1%%/##}##/##}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
if [[ ${zurl} == /* ]]; then
|
|
||||||
_zdirs[${zname}]=${zurl%%/##}
|
|
||||||
zurl=
|
|
||||||
else
|
|
||||||
_zdirs[${zname}]=${ZIM_HOME}/modules/${zname}
|
|
||||||
fi
|
|
||||||
if [[ ${+_zurls[${zname}]} -ne 0 && ${_zurls[${zname}]} != ${zurl} ]]; then
|
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Module already defined with a different URL. Expected <%= bold %>'${_zurls[${zname}]}$'<%= normal %>' '' ${zusage}
|
|
||||||
_zfailed=1
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
_zurls[${zname}]=${zurl}
|
|
||||||
local -r zroot_dir=${_zdirs[${zname}]}${zroot:+/${zroot}}
|
|
||||||
_zroot_dirs+=(${zroot_dir})
|
|
||||||
# Set default values
|
|
||||||
if (( ! ${+_ztools[${zname}]} )); then
|
|
||||||
zstyle -s ':zim:zmodule' use "_ztools[${zname}]" || _ztools[${zname}]=git
|
|
||||||
fi
|
|
||||||
if (( ! ${+_ztypes[${zname}]} )) _ztypes[${zname}]=branch
|
|
||||||
if (( ! ${+_zsubmodules[${zname}]} )) _zsubmodules[${zname}]=1
|
|
||||||
# Set values from options
|
|
||||||
while (( # > 0 )); do
|
|
||||||
case ${1} in
|
|
||||||
-b|--branch|-t|--tag|-u|--use|--on-pull|--if|--if-command|-f|--fpath|-a|--autoload|-s|--source|-c|--cmd)
|
|
||||||
if (( # < 2 )); then
|
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Missing argument for zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
|
|
||||||
_zfailed=1
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ${1} in
|
|
||||||
-b|--branch|-t|--tag|-u|--use|--no-submodules)
|
|
||||||
if [[ -z ${zurl} ]] _zimfw_print -u2 -R $'<%= yellow %><%= warn %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalyellow %> The zmodule option <%= bold %>'${1}$'<%= normalyellow %> has no effect for external modules<%= normal %>'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
case ${1} in
|
|
||||||
-b|--branch)
|
|
||||||
shift
|
|
||||||
_ztypes[${zname}]=branch
|
|
||||||
_zrevs[${zname}]=${1}
|
|
||||||
;;
|
|
||||||
-t|--tag)
|
|
||||||
shift
|
|
||||||
_ztypes[${zname}]=tag
|
|
||||||
_zrevs[${zname}]=${1}
|
|
||||||
;;
|
|
||||||
-u|--use)
|
|
||||||
shift
|
|
||||||
_ztools[${zname}]=${1}
|
|
||||||
;;
|
|
||||||
--no-submodules) _zsubmodules[${zname}]=0 ;;
|
|
||||||
-z|--frozen) _zfrozens[${zname}]=1 ;;
|
|
||||||
--on-pull)
|
|
||||||
shift
|
|
||||||
zarg=${1}
|
|
||||||
if [[ -n ${zroot} ]] zarg="(builtin cd -q ${zroot}; ${zarg})"
|
|
||||||
_zonpulls[${zname}]="${_zonpulls[${zname}]+${_zonpulls[${zname}]}; }${zarg}"
|
|
||||||
;;
|
|
||||||
--if)
|
|
||||||
shift
|
|
||||||
_zifs[${zroot_dir}]=${1}
|
|
||||||
;;
|
|
||||||
--if-command)
|
|
||||||
shift
|
|
||||||
_zifs[${zroot_dir}]="(( \${+commands[${1}]} ))"
|
|
||||||
;;
|
|
||||||
-f|--fpath)
|
|
||||||
shift
|
|
||||||
zarg=${1}
|
|
||||||
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
|
|
||||||
zfpaths+=(${zarg})
|
|
||||||
;;
|
|
||||||
-a|--autoload)
|
|
||||||
shift
|
|
||||||
zfunctions+=(${1})
|
|
||||||
;;
|
|
||||||
-s|--source)
|
|
||||||
shift
|
|
||||||
zarg=${1}
|
|
||||||
if [[ ${zarg} != /* ]] zarg=${zroot_dir}/${zarg}
|
|
||||||
zcmds+=('source '${(qqq)zarg:a})
|
|
||||||
;;
|
|
||||||
-c|--cmd)
|
|
||||||
shift
|
|
||||||
zcmds+=(${1//{}/${(qqq)zroot_dir:a}})
|
|
||||||
;;
|
|
||||||
-d|--disabled) _zdisabled_root_dirs+=(${zroot_dir}) ;;
|
|
||||||
*)
|
|
||||||
print -u2 -lR $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalred %> Unknown zmodule option <%= bold %>'${1}$'<%= normal %>' '' ${zusage}
|
|
||||||
_zfailed=1
|
|
||||||
return 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
if (( _zflags & 1 )); then
|
|
||||||
_znames+=(${zname})
|
|
||||||
fi
|
|
||||||
if (( _zflags & 2 )); then
|
|
||||||
if [[ ! -e ${zroot_dir} ]]; then
|
|
||||||
print -u2 -R $'<%= red %><%= error %>'${funcfiletrace[1]}$':<%= bold %>'${zname}': '${zroot_dir}$'<%= normalred %> not found<%= normal %>'
|
|
||||||
_zfailed=1
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
|
||||||
zfpaths=(${zroot_dir}/functions(NF))
|
|
||||||
# _* functions are autoloaded by compinit
|
|
||||||
# prompt_*_setup functions are autoloaded by promptinit
|
|
||||||
zfunctions=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
|
||||||
local -ra prezto_scripts=(${zroot_dir}/init.zsh(N))
|
|
||||||
if (( ${#zfpaths} && ${#prezto_scripts} )); then
|
|
||||||
# this follows the prezto module format, no need to check for other scripts
|
|
||||||
zcmds=('source '${(qqq)^prezto_scripts:a})
|
|
||||||
else
|
|
||||||
# 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]))
|
|
||||||
zcmds=('source '${(qqq)^zscripts:a})
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if (( ! ${#zfpaths} && ! ${#zfunctions} && ! ${#zcmds} )); then
|
|
||||||
_zimfw_print -u2 -lR $'<%= yellow %><%= warn %>'${funcfiletrace[1]}$':<%= bold %>'${zname}$':<%= normalyellow %> Nothing found to be initialized. Customize the module name, root or initialization with <%= bold %>zmodule<%= normalyellow %> options.<%= normal %>' '' ${zusage}
|
|
||||||
fi
|
|
||||||
# Prefix is added to all _zfpaths, _zfunctions and _zcmds to distinguish the originating root dir
|
|
||||||
local -r zpre=${zroot_dir}$'\0'
|
|
||||||
_zfpaths+=(${zpre}${^zfpaths})
|
|
||||||
_zfunctions+=(${zpre}${^zfunctions})
|
|
||||||
zcmds=(${zcmds//${HOME}/\${HOME}})
|
|
||||||
_zcmds+=(${zpre}${^zcmds})
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -1,12 +1,7 @@
|
||||||
autoload -Uz is-at-least && if ! is-at-least <%= min_zsh_version %>; then
|
autoload -Uz is-at-least && if ! is-at-least <%= min_zsh_version %>; then
|
||||||
print -u2 -R $'<%= red %>'${0}$': Error starting zimfw. You\'re using Zsh version <%= bold %>'${ZSH_VERSION}$'<%= normalred %> and versions < <%= bold %><%= min_zsh_version %><%= normalred %> are not supported. Upgrade your Zsh.<%= normal %>'
|
print -u2 -R "${0}: Error starting Zim. You're using Zsh version ${ZSH_VERSION} and versions < <%= min_zsh_version %> are not supported. Update your Zsh."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
autoload -Uz zargs
|
|
||||||
|
|
||||||
if (( ! ${+ZIM_HOME} )); then
|
# Define Zim location
|
||||||
print -u2 -R $'<%= red %>'${0}$': <%= bold %>ZIM_HOME<%= normalred %> not defined<%= normal %>'
|
: ${ZIM_HOME=${0:A:h}}
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Define zimfw location
|
|
||||||
typeset -g __ZIMFW_FILE=${0}
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
_zimfw_print() {
|
_zimfw_print() {
|
||||||
if (( _zprintlevel > 0 )) print "${@}"
|
if (( ! _zquiet )); then
|
||||||
|
print "${@}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
_zimfw_mv() {
|
_zimfw_mv() {
|
||||||
local -a cklines
|
if command cmp -s ${2} ${1}; then
|
||||||
if cklines=(${(f)"$(command cksum ${1} ${2} 2>/dev/null)"}) && \
|
_zimfw_print -PR "<%= okay %>%B${2}:%b Already up to date"
|
||||||
[[ ${${(z)cklines[1]}[1,2]} == ${${(z)cklines[2]}[1,2]} ]]; then
|
|
||||||
_zimfw_print -R $'<%= okay %><%= bold %>'${2}$':<%= normal %> Already up to date'
|
|
||||||
else
|
else
|
||||||
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 -PR "<%= okay %>%B${2}:%b Updated. Restart your terminal for changes to take effect."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,13 @@
|
||||||
_zimfw_build_init() {
|
_zimfw_build_init() {
|
||||||
local -r ztarget=${ZIM_HOME}/init.zsh
|
local -r ztarget=${ZIM_HOME}/init.zsh
|
||||||
# Force update of init.zsh if it's older than .zimrc
|
# Force update of init.zsh if it's older than .zimrc
|
||||||
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} ]]; then
|
if [[ ${ztarget} -ot <%= home %>/.zimrc ]]; then
|
||||||
command mv -f ${ztarget}{,.old} || return 1
|
command mv -f ${ztarget}{,.old} || return 1
|
||||||
fi
|
fi
|
||||||
_zimfw_mv =(
|
_zimfw_mv =(
|
||||||
print -R 'if (( ${+ZIM_HOME} )) zimfw() { source '${${(qqq)__ZIMFW_FILE}/${HOME}/\${HOME}}' "${@}" }'
|
print -R "zimfw() { source ${ZIM_HOME}/zimfw.zsh \"\${@}\" }"
|
||||||
local zroot_dir zpre
|
(( ${#_zfpaths} )) && print -R 'fpath=('${_zfpaths:A}' ${fpath})'
|
||||||
local -a zif_functions zif_cmds zroot_functions zroot_cmds
|
(( ${#_zfunctions} )) && print -R 'autoload -Uz '${_zfunctions}
|
||||||
local -a zfunctions=(${_zfunctions}) zcmds=(${_zcmds})
|
print -Rn ${(F):-source ${^_zscripts:A}}
|
||||||
# Keep fpath constant regardless of "if" root dirs, to avoid confusing compinit.
|
|
||||||
# Move all from zfunctions and zcmds with "if" root dirs prefixes.
|
|
||||||
for zroot_dir in ${_zroot_dirs}; do
|
|
||||||
if (( ${+_zifs[${zroot_dir}]} )); then
|
|
||||||
zpre=${zroot_dir}$'\0'
|
|
||||||
zif_functions+=(${(M)zfunctions:#${zpre}*})
|
|
||||||
zif_cmds+=(${(M)zcmds:#${zpre}*})
|
|
||||||
zfunctions=(${zfunctions:#${zpre}*})
|
|
||||||
zcmds=(${zcmds:#${zpre}*})
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
zpre=$'*\0'
|
|
||||||
if (( ${#_zfpaths} )) print -R 'fpath=('${${(qqq)${_zfpaths#${~zpre}}:a}/${HOME}/\${HOME}}' ${fpath})'
|
|
||||||
if (( ${#zfunctions} )) print -R 'autoload -Uz -- '${zfunctions#${~zpre}}
|
|
||||||
for zroot_dir in ${_zroot_dirs}; do
|
|
||||||
zpre=${zroot_dir}$'\0'
|
|
||||||
if (( ${+_zifs[${zroot_dir}]} )); then
|
|
||||||
zroot_functions=(${${(M)zif_functions:#${zpre}*}#${zpre}})
|
|
||||||
zroot_cmds=(${${(M)zif_cmds:#${zpre}*}#${zpre}})
|
|
||||||
if (( ${#zroot_functions} || ${#zroot_cmds} )); then
|
|
||||||
print -R 'if '${_zifs[${zroot_dir}]}'; then'
|
|
||||||
if (( ${#zroot_functions} )) print -R ' autoload -Uz -- '${zroot_functions}
|
|
||||||
if (( ${#zroot_cmds} )) print -R ${(F):- ${^zroot_cmds}}
|
|
||||||
print fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
zroot_cmds=(${${(M)zcmds:#${zpre}*}#${zpre}})
|
|
||||||
if (( ${#zroot_cmds} )) print -R ${(F)zroot_cmds}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
) ${ztarget}
|
) ${ztarget}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
_zimfw_build_login_init() {
|
_zimfw_build_login_init() {
|
||||||
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||||
# Force update of login_init.zsh if it's older than .zimrc
|
|
||||||
if [[ ${ztarget} -ot ${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} ]]; then
|
|
||||||
command mv -f ${ztarget}{,.old} || return 1
|
|
||||||
fi
|
|
||||||
_zimfw_mv =(
|
_zimfw_mv =(
|
||||||
print '# Do nothing. This file is deprecated.'
|
print -Rn "<%= render_escaped("src/templates/login_init.zsh.erb") %>"
|
||||||
) ${ztarget}
|
) ${ztarget}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
_zimfw_build() {
|
_zimfw_build() {
|
||||||
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print 'Done with build.'
|
_zimfw_build_init && _zimfw_build_login_init && _zimfw_print -P '<%= done %>Done with build.'
|
||||||
}
|
}
|
||||||
|
|
127
src/stage2/30_zmodule.zsh.erb
Normal file
127
src/stage2/30_zmodule.zsh.erb
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
zmodule() {
|
||||||
|
local -r zusage="
|
||||||
|
Usage: %B${0}%b <url> [%B-n%b|%B--name%b <module_name>] [options]
|
||||||
|
|
||||||
|
Repository options:
|
||||||
|
%B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module
|
||||||
|
%B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module
|
||||||
|
%B-z%b|%B--frozen%b Don't install or update the module
|
||||||
|
|
||||||
|
Startup options:
|
||||||
|
%B-f%b|%B--fpath%b <path> Add specified path to fpath
|
||||||
|
%B-a%b|%B--autoload%b <function_name> Autoload specified function
|
||||||
|
%B-s%b|%B--source%b <file_path> Source specified file
|
||||||
|
%B-d%b|%B--disabled%b Don't use or uninstall the module
|
||||||
|
"
|
||||||
|
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
|
||||||
|
print -u2 -PR "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f"$'\n'${zusage}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if (( ! # )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
|
||||||
|
local zmodule=${1:t} zurl=${1}
|
||||||
|
local ztype=branch zrev=master
|
||||||
|
local -i zdisabled=0 zfrozen=0
|
||||||
|
local -a zfpaths zfunctions zscripts
|
||||||
|
local zarg
|
||||||
|
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||||
|
zmodule=${zmodule%.git}
|
||||||
|
elif [[ ${zurl} != /* ]]; then
|
||||||
|
# Count number of slashes
|
||||||
|
case ${#zurl//[^\/]/} in
|
||||||
|
0) zurl="https://github.com/zimfw/${zurl}.git" ;;
|
||||||
|
1) zurl="https://github.com/${zurl}.git" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
if [[ ${1} == (-n|--name) ]]; then
|
||||||
|
if (( # < 2 )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
zmodule=${1}
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
||||||
|
while (( # > 0 )); do
|
||||||
|
case ${1} in
|
||||||
|
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||||
|
if (( # < 2 )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ${1} in
|
||||||
|
-b|--branch)
|
||||||
|
shift
|
||||||
|
ztype=branch
|
||||||
|
zrev=${1}
|
||||||
|
;;
|
||||||
|
-t|--tag)
|
||||||
|
shift
|
||||||
|
ztype=tag
|
||||||
|
zrev=${1}
|
||||||
|
;;
|
||||||
|
-z|--frozen) zfrozen=1 ;;
|
||||||
|
-f|--fpath)
|
||||||
|
shift
|
||||||
|
zarg=${1}
|
||||||
|
[[ ${zarg} != /* ]] && zarg=${zdir}/${zarg}
|
||||||
|
zfpaths+=(${zarg})
|
||||||
|
;;
|
||||||
|
-a|--autoload)
|
||||||
|
shift
|
||||||
|
zfunctions+=(${1})
|
||||||
|
;;
|
||||||
|
-s|--source)
|
||||||
|
shift
|
||||||
|
zarg=${1}
|
||||||
|
[[ ${zarg} != /* ]] && zarg=${zdir}/${zarg}
|
||||||
|
zscripts+=(${zarg})
|
||||||
|
;;
|
||||||
|
-d|--disabled) zdisabled=1 ;;
|
||||||
|
*)
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if (( _zprepare_xargs )); then
|
||||||
|
if (( ! zfrozen )); then
|
||||||
|
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if (( zdisabled )); then
|
||||||
|
_zdisableds+=(${zmodule})
|
||||||
|
else
|
||||||
|
if [[ ! -d ${zdir} ]]; then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
||||||
|
if (( ! ${#zfunctions} )); then
|
||||||
|
# _* functions are autoloaded by compinit
|
||||||
|
# prompt_*_setup functions are autoloaded by promptinit
|
||||||
|
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||||
|
fi
|
||||||
|
if (( ! ${#zscripts} )); then
|
||||||
|
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||||
|
fi
|
||||||
|
_zfpaths+=(${zfpaths})
|
||||||
|
_zfunctions+=(${zfunctions})
|
||||||
|
_zscripts+=(${zscripts})
|
||||||
|
_zmodules+=(${zmodule})
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,25 +1,8 @@
|
||||||
_zimfw_source_zimrc() {
|
_zimfw_source_zimrc() {
|
||||||
<%= render_all("src/functions/*.erb") %>
|
local -ri _zprepare_xargs=${1}
|
||||||
{
|
local -i _zfailed=0
|
||||||
local -r ztarget=${ZIM_CONFIG_FILE:-<%= home %>/.zimrc} _zflags=${1}
|
if ! source <%= home %>/.zimrc || (( _zfailed )); then
|
||||||
local -i _zfailed=0
|
print -u2 -PR "%F{red}<%= failed %>Failed to source %B<%= home %>/.zimrc%b%f"
|
||||||
if ! source ${ztarget} || (( _zfailed )); then
|
return 1
|
||||||
print -u2 -R $'<%= red %>Failed to source <%= bold %>'${ztarget}$'<%= normal %>'
|
fi
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if (( _zflags & 1 && ${#_znames} == 0 )); then
|
|
||||||
print -u2 -R $'<%= red %>No modules defined in <%= bold %>'${ztarget}$'<%= normal %>'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Remove all from _zfpaths, _zfunctions and _zcmds with disabled root dirs prefixes
|
|
||||||
local zroot_dir zpre
|
|
||||||
for zroot_dir in ${_zdisabled_root_dirs}; do
|
|
||||||
zpre=${zroot_dir}$'\0'
|
|
||||||
_zfpaths=(${_zfpaths:#${zpre}*})
|
|
||||||
_zfunctions=(${_zfunctions:#${zpre}*})
|
|
||||||
_zcmds=(${_zcmds:#${zpre}*})
|
|
||||||
done
|
|
||||||
} always {
|
|
||||||
unfunction zmodule
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
_zimfw_list_unuseds() {
|
|
||||||
local -i i=1
|
|
||||||
local zinstalled=(${ZIM_HOME}/modules/*(N/))
|
|
||||||
local -r zdirs=(${(v)_zdirs})
|
|
||||||
# Search into subdirectories
|
|
||||||
while (( i <= ${#zinstalled} )); do
|
|
||||||
if (( ${zdirs[(I)${zinstalled[i]}/*]} )); then
|
|
||||||
zinstalled+=(${zinstalled[i]}/*(N/))
|
|
||||||
zinstalled[i]=()
|
|
||||||
else
|
|
||||||
(( i++ ))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
# Unused = all installed dirs not in zdirs
|
|
||||||
_zunused_dirs=(${zinstalled:|zdirs})
|
|
||||||
local zunused
|
|
||||||
for zunused (${_zunused_dirs}) _zimfw_print -R $'<%= bold %>'${zunused:t}$':<%= normal %> '${zunused}${1}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
_zimfw_check_dumpfile() {
|
|
||||||
_zimfw_print -u2 $'<%= yellow %><%= warn %>Deprecated action. This is now handled by the completion module alone.<%= normal %>'
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
_zimfw_check_version() {
|
|
||||||
if (( ${1} )); then
|
|
||||||
if (( ${2} )); then
|
|
||||||
# background check
|
|
||||||
if [[ -w ${_zversion_target:h} ]]; then
|
|
||||||
print -R ${${${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs --sort=-v:refname \
|
|
||||||
https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &!
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# foreground check
|
|
||||||
local tags
|
|
||||||
tags=$(command git ls-remote --tags --refs --sort=-v:refname https://github.com/zimfw/zimfw.git 'v*') || return 1
|
|
||||||
>! ${_zversion_target} <<<${${${(f)tags}##*v}[1]} || return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ -f ${_zversion_target} ]]; then
|
|
||||||
local -r zlatest_version=$(<${_zversion_target})
|
|
||||||
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
|
|
||||||
_zimfw_print -u2 -R $'<%= yellow %>Latest zimfw version is <%= bold %>'${zlatest_version}$'<%= normalyellow %>. You\'re using version <%= bold %>'${_zversion}$'<%= normalyellow %>. Run <%= bold %>zimfw upgrade<%= normalyellow %> to upgrade.<%= normal %>'
|
|
||||||
return 4
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -1,8 +1,7 @@
|
||||||
_zimfw_clean_compiled() {
|
_zimfw_clean_compiled() {
|
||||||
# Array with unique dirs. ${ZIM_HOME} or any subdirectory should only occur once.
|
|
||||||
local -Ur zscriptdirs=(${ZIM_HOME:A} ${${(v)_zdirs##${ZIM_HOME:A}/*}:A})
|
|
||||||
local zopt
|
local zopt
|
||||||
if (( _zprintlevel > 0 )) zopt=-v
|
(( ! _zquiet )) && zopt='-v'
|
||||||
command rm -f ${zopt} ${^zscriptdirs}/**/*.zwc(|.old)(N) && \
|
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
|
||||||
_zimfw_print $'Done with clean-compiled. Restart your terminal or run <%= bold %>zimfw compile<%= normal %> to re-compile.'
|
command rm -f ${zopt} <%= home %>/<%= startup_files_glob %>.zwc(|.old)(N) || return 1
|
||||||
|
_zimfw_print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
_zimfw_clean_dumpfile() {
|
_zimfw_clean_dumpfile() {
|
||||||
local zdumpfile zopt
|
local zdumpfile zopt
|
||||||
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
||||||
if (( _zprintlevel > 0 )) zopt=-v
|
(( ! _zquiet )) && zopt='-v'
|
||||||
command rm -f ${zopt} ${zdumpfile}(|.dat|.zwc(|.old))(N) && \
|
command rm -f ${zopt} ${zdumpfile}(|.zwc(|.old))(N) || return 1
|
||||||
_zimfw_print -R "Done with clean-dumpfile.${_zrestartmsg}"
|
_zimfw_print -P '<%= done %>Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,3 @@
|
||||||
_zimfw_compile() {
|
_zimfw_compile() {
|
||||||
# Compile zimfw scripts
|
source ${ZIM_HOME}/login_init.zsh "${@}"
|
||||||
local zroot_dir zfile
|
|
||||||
for zroot_dir in ${_zroot_dirs:|_zdisabled_root_dirs}; do
|
|
||||||
if [[ ! -w ${zroot_dir} ]]; then
|
|
||||||
_zimfw_print -R $'<%= yellow %><%= warn %><%= bold %>'${zroot_dir}$':<%= normalyellow %> No write permission, unable to compile.<%= normal %>'
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
for zfile in ${zroot_dir}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
|
||||||
if [[ ! ${zfile}.zwc -nt ${zfile} ]]; then
|
|
||||||
zcompile -UR ${zfile} && _zimfw_print -R $'<%= okay %><%= bold %>'${zfile}$'.zwc:<%= normal %> Compiled'
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
_zimfw_print 'Done with compile.'
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print -R 'zimfw version: '${_zversion}' (built at <%= Time.now.utc %>, previous commit is <%= `git rev-parse --short HEAD | tr -d '\r\n'` %>)'
|
print 'Zim version: <%= version %> (previous commit is <%= `git rev-parse --short HEAD | tr -d '\r\n'` %>)'
|
||||||
local zparam
|
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||||
for zparam in LANG ${(Mk)parameters:#LC_*} OSTYPE TERM TERM_PROGRAM TERM_PROGRAM_VERSION ZIM_HOME ZSH_VERSION; do
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
print -R ${(r.22....:.)zparam}${(P)zparam}
|
print -R 'System info: '$(command uname -a)
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
_zimfw_uninstall() {
|
_zimfw_uninstall() {
|
||||||
local zopt
|
local zopt zdir zmodule
|
||||||
if (( _zprintlevel > 0 )) zopt=-v
|
(( ! _zquiet )) && zopt='-v'
|
||||||
if (( ${#_zunused_dirs} )); then
|
for zdir in ${ZIM_HOME}/modules/*(N/); do
|
||||||
if (( _zprintlevel <= 0 )) || read -q "?Uninstall ${#_zunused_dirs} module(s) listed above [y/N]? "; then
|
zmodule=${zdir:t}
|
||||||
_zimfw_print
|
# If _zmodules and _zdisableds do not contain the zmodule
|
||||||
command rm -rf ${zopt} ${_zunused_dirs} || return 1
|
if (( ! ${_zmodules[(I)${zmodule}]} && ! ${_zdisableds[(I)${zmodule}]} )); then
|
||||||
|
command rm -rf ${zopt} ${zdir} || return 1
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
_zimfw_print 'Done with uninstall.'
|
_zimfw_print -P '<%= done %>Done with uninstall.'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,14 @@
|
||||||
_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
|
||||||
if [[ ! -w ${ztarget:h} ]]; then
|
local -r zurl=https://raw.githubusercontent.com/zimfw/zimfw/master/zimfw.zsh
|
||||||
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[wget]} )); then
|
||||||
command curl -fsSL -o ${ztarget}.new.gz ${zurl} || return 1
|
command wget -nv -O ${ztarget}.new ${zurl} || return 1
|
||||||
else
|
else
|
||||||
local zopt
|
command curl -fsSL -o ${ztarget}.new ${zurl} || return 1
|
||||||
if (( _zprintlevel <= 1 )) zopt=-q
|
|
||||||
if ! command wget -nv ${zopt} -O ${ztarget}.new.gz ${zurl}; then
|
|
||||||
if (( _zprintlevel <= 1 )); then
|
|
||||||
print -u2 -R $'<%= red %>Failed to download <%= bold %>'${zurl}$'<%= normalred %>. Use <%= bold %>-v<%= normalred %> option to see details.<%= normal %>'
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
command gunzip -f ${ztarget}.new.gz || return 1
|
_zimfw_mv ${ztarget}{.new,} && _zimfw_print -P '<%= done %>Done with upgrade.'
|
||||||
# .latest_version can be outdated and will yield a false warning if zimfw is
|
|
||||||
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
|
||||||
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
|
||||||
_zimfw_print 'Done with upgrade.'
|
|
||||||
} always {
|
} always {
|
||||||
command rm -f ${ztarget}.new{,.gz}
|
command rm -f ${ztarget}.new
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
_zimfw_run_list() {
|
|
||||||
local -r zname=${1}
|
|
||||||
local -r zdir=${_zdirs[${zname}]}
|
|
||||||
print -nR $'<%= bold %>'${zname}$':<%= normal %> '${zdir}
|
|
||||||
if [[ -z ${_zurls[${zname}]} ]] print -n ' (external)'
|
|
||||||
if (( ${_zfrozens[${zname}]} )) print -n ' (frozen)'
|
|
||||||
if (( ${_zdisabled_root_dirs[(I)${zdir}]} )) print -n ' (disabled)'
|
|
||||||
print
|
|
||||||
if (( _zprintlevel > 1 )); then
|
|
||||||
if [[ ${_zfrozens[${zname}]} -eq 0 && -n ${_zurls[${zname}]} ]]; then
|
|
||||||
print -nR " From: ${_zurls[${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
|
|
||||||
if [[ -n ${_zonpulls[${zname}]} ]] print -R " On-pull: ${_zonpulls[${zname}]}"
|
|
||||||
fi
|
|
||||||
# Match the current module dir prefix from _zroot_dirs
|
|
||||||
local -r zroot_dirs=(${(M)_zroot_dirs:#${zdir}/*})
|
|
||||||
if (( ${#zroot_dirs} )); then
|
|
||||||
print ' Additional root:'
|
|
||||||
local zroot_dir
|
|
||||||
for zroot_dir in ${zroot_dirs}; do
|
|
||||||
print -nR " ${zroot_dir}"
|
|
||||||
if (( ${_zdisabled_root_dirs[(I)${zroot_dir}]} )) print -n ' (disabled)'
|
|
||||||
print
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
# Match and remove the prefix from _zfpaths, _zfunctions and _zcmds
|
|
||||||
local -r zpre="${(q)zdir}(|/*)"$'\0'
|
|
||||||
local -r zfpaths=(${${(M)_zfpaths:#${~zpre}*}#${~zpre}}) zfunctions=(${${(M)_zfunctions:#${~zpre}*}#${~zpre}}) zcmds=(${${(M)_zcmds:#${~zpre}*}#${~zpre}})
|
|
||||||
if (( ${#zfpaths} )) print -R ' fpath: '${zfpaths}
|
|
||||||
if (( ${#zfunctions} )) print -R ' autoload: '${zfunctions}
|
|
||||||
if (( ${#zcmds} )) print -R ' cmd: '${(j:; :)zcmds}
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
_zimfw_print_error() {
|
|
||||||
print -u2 -lR $'<%= clear_line %><%= red %><%= error %><%= bold %>'${_zname}$':<%= normalred %> '${1}$'<%= normal %>' ${2:+${(F):- ${(f)^2}}}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
_zimfw_print_okay() {
|
|
||||||
if (( _zprintlevel > ${2:-0} )) print -lR $'<%= clear_line %><%= okay %><%= bold %>'${_zname}$':<%= normal %> '${1} ${3:+${(F):- ${(f)^3}}}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
_zimfw_print_warn() {
|
|
||||||
_zimfw_print -u2 -R $'<%= clear_line %><%= yellow %><%= warn %><%= bold %>'${_zname}$':<%= normalyellow %> '${1}$'<%= normal %>'
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
_zimfw_pull_print_okay() {
|
|
||||||
# Useb by tools, which run in a subshell
|
|
||||||
if [[ -n ${ONPULL} ]]; then
|
|
||||||
if ! ERR=$(builtin cd -q ${DIR} 2>&1 && builtin eval ${ONPULL} 2>&1); then
|
|
||||||
_zimfw_print_error 'Error during on-pull' ${ERR}
|
|
||||||
return 1
|
|
||||||
elif [[ ${_zprintlevel} -gt 1 && -n ${ERR} ]]; then
|
|
||||||
# Overrides ${3} to include the on-pull output, to be used by _zimfw_print_okay below.
|
|
||||||
builtin set ${1} ${2:-0} ${3:+${3}$'\n'}'On-pull output:'$'\n'${ERR}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_zimfw_print_okay "${@}"
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
_zimfw_download_tarball() {
|
|
||||||
if [[ ${URL} =~ <%= url_regex %> ]]; then
|
|
||||||
readonly HOST=${match[3]}
|
|
||||||
readonly REPO=${match[4]%.git}
|
|
||||||
fi
|
|
||||||
if [[ ${HOST} != github.com || -z ${REPO} ]]; then
|
|
||||||
_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
|
|
||||||
fi
|
|
||||||
readonly HEADERS_TARGET=${DIR}/${TEMP}_headers
|
|
||||||
{
|
|
||||||
if [[ -r ${INFO_TARGET} ]]; then
|
|
||||||
readonly INFO=("${(@f)"$(<${INFO_TARGET})"}")
|
|
||||||
if [[ ${URL} != ${INFO[1]} ]]; then
|
|
||||||
_zimfw_print_error "The zimfw degit 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}
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
if [[ -z ${INFO_HEADER} ]] return 0
|
|
||||||
if (( ${+commands[curl]} )); then
|
|
||||||
command curl -IfsL -H ${INFO_HEADER} ${TARBALL_URL} >${HEADERS_TARGET}
|
|
||||||
else
|
|
||||||
command wget --spider -qS --header=${INFO_HEADER} ${TARBALL_URL} 2>${HEADERS_TARGET}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if (( ${+commands[curl]} )); then
|
|
||||||
if ! ERR=$(command curl -fsSL ${INFO_HEADER:+-H} ${INFO_HEADER} -o ${TARBALL_TARGET} -D ${HEADERS_TARGET} ${TARBALL_URL} 2>&1); then
|
|
||||||
_zimfw_print_error "Error downloading ${TARBALL_URL} with curl" ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# wget returns 8 when 304 Not Modified, so we cannot use wget's error codes
|
|
||||||
command wget -qS ${INFO_HEADER:+--header=${INFO_HEADER}} -O ${TARBALL_TARGET} ${TARBALL_URL} 2>${HEADERS_TARGET}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
while IFS= read -r HEADER; do
|
|
||||||
HEADER=${${HEADER## ##}%%$'\r'##}
|
|
||||||
if [[ ${HEADER} == HTTP/* ]]; then
|
|
||||||
HTTP_CODE=${${(s: :)HEADER}[2]}
|
|
||||||
elif [[ ${${(L)HEADER%%:*}%% ##} == etag ]]; then
|
|
||||||
ETAG=${${HEADER#*:}## ##}
|
|
||||||
fi
|
|
||||||
done < ${HEADERS_TARGET}
|
|
||||||
if (( HTTP_CODE == 304 )); then
|
|
||||||
# Not Modified
|
|
||||||
command rm -f ${TARBALL_TARGET} 2>/dev/null
|
|
||||||
return 0
|
|
||||||
elif (( HTTP_CODE != 200 )); then
|
|
||||||
_zimfw_print_error "Error downloading ${TARBALL_URL}, HTTP code ${HTTP_CODE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ -z ${ETAG} ]]; then
|
|
||||||
_zimfw_print_error "Error downloading ${TARBALL_URL}, no ETag header found in response"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
command touch ${TARBALL_TARGET} # Update available
|
|
||||||
else
|
|
||||||
if ! print -lR "${URL}" "${REV}" "If-None-Match: ${ETAG}" >! ${INFO_TARGET} 2>/dev/null; then
|
|
||||||
_zimfw_print_error "Error creating or updating ${INFO_TARGET}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
} always {
|
|
||||||
command rm -f ${HEADERS_TARGET} 2>/dev/null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_zimfw_untar_tarball() {
|
|
||||||
if ! ERR=$(command tar -C ${1} -xzf ${TARBALL_TARGET} 2>&1); then
|
|
||||||
_zimfw_print_error "Error extracting ${TARBALL_TARGET}" ${ERR}
|
|
||||||
return 1
|
|
||||||
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() {
|
|
||||||
# This runs in a subshell
|
|
||||||
readonly -i SUBMODULES=${5}
|
|
||||||
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
|
|
||||||
case ${_zaction} in
|
|
||||||
install)
|
|
||||||
{
|
|
||||||
_zimfw_create_dir ${DIR} && _zimfw_download_tarball && _zimfw_untar_tarball ${DIR} && _zimfw_pull_print_okay Installed || return 1
|
|
||||||
} always {
|
|
||||||
# return 1 does not change ${TRY_BLOCK_ERROR}, only changes ${?}
|
|
||||||
(( TRY_BLOCK_ERROR = ? ))
|
|
||||||
command rm -f ${TARBALL_TARGET} 2>/dev/null
|
|
||||||
if (( TRY_BLOCK_ERROR )) command rm -rf ${DIR} 2>/dev/null
|
|
||||||
}
|
|
||||||
;;
|
|
||||||
check|update)
|
|
||||||
if [[ ! -r ${INFO_TARGET} ]]; then
|
|
||||||
_zimfw_print_warn $'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.'
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
readonly DIR_NEW=${DIR}${TEMP}
|
|
||||||
{
|
|
||||||
_zimfw_download_tarball || return 1
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
if [[ -e ${TARBALL_TARGET} ]]; then
|
|
||||||
_zimfw_print_okay 'Update available'
|
|
||||||
return 4
|
|
||||||
fi
|
|
||||||
_zimfw_print_okay 'Already up to date' 1
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
if [[ -e ${TARBALL_TARGET} ]]; then
|
|
||||||
_zimfw_create_dir ${DIR_NEW} && _zimfw_untar_tarball ${DIR_NEW} || return 1
|
|
||||||
if (( ${+commands[diff]} )); then
|
|
||||||
LOG=$(command diff -x '.zdegit*' -x '*.zwc' -x '*.zwc.old' -qr ${DIR} ${DIR_NEW} 2>/dev/null)
|
|
||||||
LOG=${${LOG//${DIR_NEW}/new}//${DIR}/old}
|
|
||||||
fi
|
|
||||||
if ! ERR=$({ command cp -f ${INFO_TARGET} ${DIR_NEW} && \
|
|
||||||
command rm -rf ${DIR} && command mv -f ${DIR_NEW} ${DIR} } 2>&1); then
|
|
||||||
_zimfw_print_error "Error updating ${DIR}" ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_zimfw_pull_print_okay Updated 0 ${LOG} || return 1
|
|
||||||
else
|
|
||||||
_zimfw_pull_print_okay 'Already up to date' || return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
} always {
|
|
||||||
command rm -f ${TARBALL_TARGET} 2>/dev/null
|
|
||||||
command rm -rf ${DIR_NEW} 2>/dev/null
|
|
||||||
}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# Check after successful install or update
|
|
||||||
if [[ ${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.'
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
_zimfw_tool_git() {
|
|
||||||
# This runs in a subshell
|
|
||||||
readonly -i SUBMODULES=${5}
|
|
||||||
readonly DIR=${1} URL=${2} TYPE=${3} ONPULL=${6}
|
|
||||||
REV=${4}
|
|
||||||
case ${_zaction} in
|
|
||||||
install)
|
|
||||||
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
|
|
||||||
else
|
|
||||||
_zimfw_print_error 'Error during git clone' ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
check|update)
|
|
||||||
if [[ ! -r ${DIR}/.git ]]; then
|
|
||||||
_zimfw_print_warn 'Module was not installed using git. Will not try to '${_zaction}$'. Use zmodule option <%= bold %>-z<%= normalyellow %>|<%= bold %>--frozen<%= normalyellow %> to disable this warning.'
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [[ ${URL} != $(command git -C ${DIR} config --get remote.origin.url) ]]; then
|
|
||||||
_zimfw_print_error "The git 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
|
|
||||||
_zimfw_print_error 'Error during git fetch' ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ${TYPE} == branch ]]; then
|
|
||||||
if [[ -z ${REV} ]]; then
|
|
||||||
# Get HEAD remote branch
|
|
||||||
if ! ERR=$(command git -C ${DIR} remote set-head origin -a 2>&1); then
|
|
||||||
_zimfw_print_error 'Error during git remote set-head' ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if REV=$(command git -C ${DIR} symbolic-ref --short refs/remotes/origin/HEAD 2>&1); then
|
|
||||||
REV=${REV#origin/}
|
|
||||||
else
|
|
||||||
_zimfw_print_error 'Error during git symbolic-ref' ${REV}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
TO_REV=${REV}@{u}
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
readonly -i BEHIND=$(command git -C ${DIR} rev-list --count ${REV}..${TO_REV} -- 2>/dev/null)
|
|
||||||
if (( BEHIND )); then
|
|
||||||
_zimfw_print_okay "Update available [behind ${BEHIND}]"
|
|
||||||
return 4
|
|
||||||
else
|
|
||||||
_zimfw_print_okay 'Already up to date' 1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [[ ${REV} == $(command git -C ${DIR} describe --tags --exact-match 2>/dev/null) ]]; then
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
_zimfw_print_okay 'Already up to date' 1
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
_zimfw_pull_print_okay 'Already up to date'
|
|
||||||
return ${?}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
_zimfw_print_okay 'Update available'
|
|
||||||
return 4
|
|
||||||
fi
|
|
||||||
TO_REV=${REV}
|
|
||||||
fi
|
|
||||||
LOG=$(command git -C ${DIR} log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${TO_REV} -- 2>/dev/null)
|
|
||||||
if ! ERR=$(command git -C ${DIR} checkout -q ${REV} -- 2>&1); then
|
|
||||||
_zimfw_print_error 'Error during git checkout' ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ${TYPE} == branch ]]; then
|
|
||||||
if ! OUT=$(command git -C ${DIR} merge --ff-only --no-progress -n 2>&1); then
|
|
||||||
_zimfw_print_error 'Error during git merge' ${OUT}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# keep just first line of OUT
|
|
||||||
OUT=${OUT%%($'\n'|$'\r')*}
|
|
||||||
else
|
|
||||||
OUT="Updating to ${TYPE} ${REV}"
|
|
||||||
fi
|
|
||||||
if (( SUBMODULES )); then
|
|
||||||
if ! ERR=$(command git -C ${DIR} submodule update --init --recursive -q -- 2>&1); then
|
|
||||||
_zimfw_print_error 'Error during git submodule update' ${ERR}
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_zimfw_pull_print_okay ${OUT} 0 ${LOG}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
_zimfw_tool_mkdir() {
|
|
||||||
# This runs in a subshell
|
|
||||||
readonly -i SUBMODULES=${5}
|
|
||||||
readonly DIR=${1} TYPE=${3} REV=${4} ONPULL=${6}
|
|
||||||
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
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
_zimfw_run_tool() {
|
|
||||||
local -r _zname=${1}
|
|
||||||
if [[ -z ${_zurls[${_zname}]} ]]; then
|
|
||||||
_zimfw_print_okay 'Skipping external module' 1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if (( _zfrozens[${_zname}] )); then
|
|
||||||
_zimfw_print_okay 'Skipping frozen module' 1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
case ${_zaction} in
|
|
||||||
install)
|
|
||||||
if [[ -e ${_zdirs[${_zname}]} ]]; then
|
|
||||||
_zimfw_print_okay 'Skipping already installed module' 1
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
_zimfw_print -nR $'<%= clear_line %>Installing '${_zname}'<%= ellipsis %>'
|
|
||||||
;;
|
|
||||||
check|update)
|
|
||||||
if [[ ! -d ${_zdirs[${_zname}]} ]]; then
|
|
||||||
_zimfw_print_error $'Not installed. Run <%= bold %>zimfw install<%= normalred %> to install.'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ${_zaction} == check ]]; then
|
|
||||||
if (( _zprintlevel > 1 )) print -nR $'<%= clear_line %>Checking '${_zname}'<%= ellipsis %>'
|
|
||||||
else
|
|
||||||
_zimfw_print -nR $'<%= clear_line %>Updating '${_zname}'<%= ellipsis %>'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_zimfw_print_error "Unknown action ${_zaction}"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
local -r ztool=${_ztools[${_zname}]}
|
|
||||||
case ${ztool} in
|
|
||||||
degit|git|mkdir)
|
|
||||||
_zimfw_tool_${ztool} "${_zdirs[${_zname}]}" "${_zurls[${_zname}]}" "${_ztypes[${_zname}]}" "${_zrevs[${_zname}]}" "${_zsubmodules[${_zname}]}" "${_zonpulls[${_zname}]}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_zimfw_print_error "Unknown tool ${ztool}"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
_zimfw_run_tool_action() {
|
|
||||||
local -r _zaction=${1}
|
|
||||||
_zimfw_source_zimrc 1 || return 1
|
|
||||||
zargs -n 1 -P 0 -- "${_znames[@]}" -- _zimfw_run_tool
|
|
||||||
return 0
|
|
||||||
}
|
|
|
@ -1,112 +1,66 @@
|
||||||
zimfw() {
|
zimfw() {
|
||||||
builtin emulate -L zsh -o EXTENDED_GLOB
|
local -r zusage="
|
||||||
local -r _zversion='<%= version %>' zusage=$'Usage: <%= bold %>'${0}$'<%= normal %> <action> [<%= bold %>-q<%= normal %>|<%= bold %>-v<%= normal %>]
|
Usage: %B${0}%b <action> [%B-q%b]
|
||||||
|
|
||||||
Actions:
|
Actions:
|
||||||
<%= bold %>build<%= normal %> Build <%= bold %>'${ZIM_HOME}$'/init.zsh<%= normal %> and <%= bold %>'${ZIM_HOME}$'/login_init.zsh<%= normal %>.
|
%Bbuild%b Build init.zsh and login_init.zsh
|
||||||
Also does <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see its output.
|
%Bclean%b Clean all (see below)
|
||||||
<%= bold %>clean<%= normal %> Clean all. Does both <%= bold %>clean-compiled<%= normal %> and <%= bold %>clean-dumpfile<%= normal %>.
|
%Bclean-compiled%b Clean Zsh compiled files
|
||||||
<%= bold %>clean-compiled<%= normal %> Clean Zsh compiled files.
|
%Bclean-dumpfile%b Clean completion dump file
|
||||||
<%= bold %>clean-dumpfile<%= normal %> Clean completion dumpfile.
|
%Bcompile%b Compile Zsh files
|
||||||
<%= bold %>compile<%= normal %> Compile Zsh files.
|
%Binfo%b Print Zim and system info
|
||||||
<%= bold %>help<%= normal %> Print this help.
|
%Binstall%b Install new modules
|
||||||
<%= bold %>info<%= normal %> Print zimfw and system info.
|
%Buninstall%b Delete unused modules
|
||||||
<%= bold %>list<%= normal %> List all modules currently defined in <%= bold %>'${ZIM_CONFIG_FILE:-<%= home %>/.zimrc}$'<%= normal %>.
|
%Bupdate%b Update current modules
|
||||||
Use <%= bold %>-v<%= normal %> to also see the modules details.
|
%Bupgrade%b Upgrade zimfw.zsh
|
||||||
<%= bold %>init<%= normal %> Same as <%= bold %>install<%= normal %>, but with output tailored to be used at terminal startup.
|
|
||||||
<%= bold %>install<%= normal %> Install new modules. Also does <%= bold %>build<%= normal %>, <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see their
|
|
||||||
output, any on-pull output and skipped modules.
|
|
||||||
<%= bold %>uninstall<%= normal %> Delete unused modules. Prompts for confirmation. Use <%= bold %>-q<%= normal %> for quiet uninstall.
|
|
||||||
<%= bold %>check<%= normal %> Check if updates for current modules are available. Use <%= bold %>-v<%= normal %> to also see
|
|
||||||
skipped and up to date modules.
|
|
||||||
<%= bold %>update<%= normal %> Update current modules. Also does <%= bold %>build<%= normal %>, <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see their
|
|
||||||
output, any on-pull output and skipped modules.
|
|
||||||
<%= bold %>check-version<%= normal %> Check if a new version of zimfw is available.
|
|
||||||
<%= bold %>upgrade<%= normal %> Upgrade zimfw. Also does <%= bold %>compile<%= normal %>. Use <%= bold %>-v<%= normal %> to also see its output.
|
|
||||||
<%= bold %>version<%= normal %> Print zimfw version.
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
<%= bold %>-q<%= normal %> Quiet (yes to prompts and only outputs errors)
|
%B-q%b Quiet, only outputs errors
|
||||||
<%= bold %>-v<%= normal %> Verbose (outputs more details)'
|
"
|
||||||
local -Ua _znames _zroot_dirs _zdisabled_root_dirs
|
local ztool _zmodules_xargs
|
||||||
local -A _zfrozens _ztools _zdirs _zurls _ztypes _zrevs _zsubmodules _zonpulls _zifs
|
local -a _zdisableds _zmodules _zfpaths _zfunctions _zscripts
|
||||||
local -a _zfpaths _zfunctions _zcmds _zunused_dirs
|
local -i _zquiet=0
|
||||||
local -i _zprintlevel=1
|
|
||||||
if (( # > 2 )); then
|
if (( # > 2 )); then
|
||||||
print -u2 -lR $'<%= red %>'${0}$': Too many options<%= normal %>' '' ${zusage}
|
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n'${zusage}
|
||||||
return 2
|
return 1
|
||||||
elif (( # > 1 )); then
|
elif (( # > 1 )); then
|
||||||
case ${2} in
|
case ${2} in
|
||||||
-q) _zprintlevel=0 ;;
|
-q) _zquiet=1 ;;
|
||||||
-v) _zprintlevel=2 ;;
|
|
||||||
*)
|
*)
|
||||||
print -u2 -lR $'<%= red %>'${0}': Unknown option '${2}$'<%= normal %>' '' ${zusage}
|
print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n'${zusage}
|
||||||
return 2
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
[[ -f ${_zversion_target}(#qNm-30) ]]; local -r zversion_check_force=${?}
|
|
||||||
_zimfw_check_version ${zversion_check_force} 1
|
|
||||||
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.'
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
build)
|
install)
|
||||||
_zimfw_source_zimrc 2 && _zimfw_build || return 1
|
ztool="<%= render_escaped("src/tools/install.zsh.erb") %>"
|
||||||
(( _zprintlevel-- ))
|
|
||||||
_zimfw_compile
|
|
||||||
;;
|
;;
|
||||||
check-dumpfile) _zimfw_check_dumpfile ;;
|
update)
|
||||||
clean) _zimfw_source_zimrc 2 && _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
ztool="<%= render_escaped("src/tools/update.zsh.erb") %>"
|
||||||
clean-compiled) _zimfw_source_zimrc 2 && _zimfw_clean_compiled ;;
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
||||||
|
init) _zimfw_source_zimrc && _zimfw_build ;;
|
||||||
|
clean) _zimfw_clean_compiled && _zimfw_clean_dumpfile ;;
|
||||||
|
clean-compiled) _zimfw_clean_compiled ;;
|
||||||
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
clean-dumpfile) _zimfw_clean_dumpfile ;;
|
||||||
compile) _zimfw_source_zimrc 2 && _zimfw_compile ;;
|
compile) _zimfw_build_login_init && _zimfw_compile ${2} ;;
|
||||||
help) print -R ${zusage} ;;
|
|
||||||
info) _zimfw_info ;;
|
info) _zimfw_info ;;
|
||||||
list)
|
|
||||||
_zimfw_source_zimrc 3 && zargs -n 1 -- "${_znames[@]}" -- _zimfw_run_list && \
|
|
||||||
_zimfw_list_unuseds ' (unused)'
|
|
||||||
;;
|
|
||||||
check)
|
|
||||||
_zrestartmsg=
|
|
||||||
_zimfw_run_tool_action ${1} || return 1
|
|
||||||
(( _zprintlevel-- ))
|
|
||||||
_zimfw_print -R "Done with ${1}." # Only printed in verbose mode
|
|
||||||
;;
|
|
||||||
init)
|
|
||||||
_zrestartmsg=
|
|
||||||
_zimfw_run_tool_action install || return 1
|
|
||||||
(( _zprintlevel-- ))
|
|
||||||
_zimfw_print 'Done with install.' # Only printed in verbose mode
|
|
||||||
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
|
|
||||||
;;
|
|
||||||
install|update)
|
install|update)
|
||||||
_zimfw_run_tool_action ${1} || return 1
|
_zimfw_source_zimrc 1 || return 1
|
||||||
_zimfw_print -R "Done with ${1}.${_zrestartmsg}"
|
print -Rn ${_zmodules_xargs} | xargs -0 -n6 -P10 zsh -c ${ztool} ${1} && \
|
||||||
(( _zprintlevel-- ))
|
_zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." && \
|
||||||
_zimfw_source_zimrc 2 && _zimfw_build && _zimfw_compile
|
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2}
|
||||||
;;
|
;;
|
||||||
uninstall) _zimfw_source_zimrc 2 && _zimfw_list_unuseds && _zimfw_uninstall ;;
|
uninstall) _zimfw_source_zimrc && _zimfw_uninstall ;;
|
||||||
check-version) _zimfw_check_version 1 ;;
|
upgrade) _zimfw_upgrade && _zimfw_build_login_init && _zimfw_compile ${2} ;;
|
||||||
upgrade)
|
|
||||||
_zimfw_upgrade || return 1
|
|
||||||
(( _zprintlevel-- ))
|
|
||||||
_zimfw_source_zimrc 2 && _zimfw_compile
|
|
||||||
;;
|
|
||||||
version) print -R ${_zversion} ;;
|
|
||||||
*)
|
*)
|
||||||
print -u2 -lR $'<%= red %>'${0}': Unknown action '${1}$'<%= normal %>' '' ${zusage}
|
print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n'${zusage}
|
||||||
return 2
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
25
src/templates/login_init.zsh.erb
Normal file
25
src/templates/login_init.zsh.erb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
() {
|
||||||
|
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
|
||||||
|
autoload -Uz zrecompile
|
||||||
|
local zdumpfile zfile
|
||||||
|
|
||||||
|
# Compile the completion cache; significant speedup
|
||||||
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
||||||
|
if [[ -f ${zdumpfile} ]]; then
|
||||||
|
zrecompile -p ${1} ${zdumpfile} || return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compile Zsh startup files
|
||||||
|
for zfile in ${1} <%= home %>/<%= startup_files_glob %>(N-.); do
|
||||||
|
zrecompile -p ${1} ${zfile} || return 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Compile Zim scripts
|
||||||
|
for zfile in ${ZIM_HOME}/(^*test*/)#*.zsh(|-theme)(N-.); do
|
||||||
|
zrecompile -p ${1} ${zfile} || return 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ ${1} != -q ]]; then
|
||||||
|
print -P '<%= done %>Done with compile.'
|
||||||
|
fi
|
||||||
|
} "${@}"
|
20
src/tools/install.zsh.erb
Normal file
20
src/tools/install.zsh.erb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# This runs in a new shell
|
||||||
|
readonly MODULE=${1}
|
||||||
|
readonly DIR=${2}
|
||||||
|
readonly URL=${3}
|
||||||
|
readonly REV=${5}
|
||||||
|
readonly -i QUIET=${6}
|
||||||
|
readonly CLEAR_LINE=$'\E[2K\r'
|
||||||
|
if [[ -e ${DIR} ]]; then
|
||||||
|
# Already exists
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
(( ! QUIET )) && print -Rn ${CLEAR_LINE}"Installing ${MODULE}<%= ellipsis %>"
|
||||||
|
if ERR=$(command git clone -b ${REV} -q --recursive ${URL} ${DIR} 2>&1); then
|
||||||
|
if (( ! QUIET )); then
|
||||||
|
print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Installed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}}
|
||||||
|
return 1
|
||||||
|
fi
|
60
src/tools/update.zsh.erb
Normal file
60
src/tools/update.zsh.erb
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# This runs in a new shell
|
||||||
|
readonly MODULE=${1}
|
||||||
|
readonly DIR=${2}
|
||||||
|
readonly URL=${3}
|
||||||
|
readonly TYPE=${4}
|
||||||
|
readonly REV=${5}
|
||||||
|
readonly -i QUIET=${6}
|
||||||
|
readonly CLEAR_LINE=$'\E[2K\r'
|
||||||
|
(( ! QUIET )) && print -Rn ${CLEAR_LINE}"Updating ${MODULE}<%= ellipsis %>"
|
||||||
|
if ! builtin cd -q ${DIR} 2>/dev/null; then
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Not installed%f"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${PWD} != $(command git rev-parse --show-toplevel 2>/dev/null) ]]; then
|
||||||
|
# Not in repo root. Will not try to update.
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [[ ${URL} != $(command git config --get remote.origin.url) ]]; then
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b URL does not match. Expected ${URL}. Will not try to update.%f"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${TYPE} == tag ]]; then
|
||||||
|
if [[ ${REV} == $(command git describe --tags --exact-match 2>/dev/null) ]]; then
|
||||||
|
(( ! QUIET )) && print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Already up to date"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if ! ERR=$(command git fetch -pq origin ${REV} 2>&1); then
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git fetch%f"$'\n'${(F):- ${(f)^ERR}}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${TYPE} == branch ]]; then
|
||||||
|
LOG_REV=${REV}@{u}
|
||||||
|
else
|
||||||
|
LOG_REV=${REV}
|
||||||
|
fi
|
||||||
|
LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} 2>/dev/null)
|
||||||
|
if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git checkout%f"$'\n'${(F):- ${(f)^ERR}}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${TYPE} == branch ]]; then
|
||||||
|
if ! OUT=$(command git merge --ff-only --no-progress -n 2>&1); then
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git merge%f"$'\n'${(F):- ${(f)^OUT}}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# keep just first line of OUT
|
||||||
|
OUT=${OUT%%($'\n'|$'\r')*}
|
||||||
|
else
|
||||||
|
OUT="Updating to ${TYPE} ${REV}"
|
||||||
|
fi
|
||||||
|
if ERR=$(command git submodule update --init --recursive -q 2>&1); then
|
||||||
|
if (( ! QUIET )); then
|
||||||
|
[[ -n ${LOG} ]] && OUT=${OUT}$'\n'${(F):- ${(f)^LOG}}
|
||||||
|
print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${OUT}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git submodule update%f"$'\n'${(F):- ${(f)^ERR}}
|
||||||
|
return 1
|
||||||
|
fi
|
|
@ -1,27 +1,17 @@
|
||||||
<%
|
<%
|
||||||
class Zim
|
class Zim
|
||||||
attr_reader :version, :home, :min_zsh_version, :url_regex,
|
attr_reader :home, :min_zsh_version, :startup_files_glob, :version, :ellipsis, :okay, :error, :done, :failed
|
||||||
:bold, :normal, :red, :normalred, :yellow, :normalyellow, :clear_line, :ellipsis, :okay, :warn, :error
|
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@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
|
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
||||||
# but not file:///path/to/repo or /path/to/repo
|
@version = "1.0.1"
|
||||||
# ${match[3]} contains host, and ${match[4]} contains org/repo
|
|
||||||
@url_regex = "^([^:@/]+://)?([^@]+@)?([^:/]+)[:/]([^/]+/[^/]+)/?$"
|
|
||||||
@bold = "\\E[1m"
|
|
||||||
@normal = "\\E[0m"
|
|
||||||
@yellow = "\\E[33m"
|
|
||||||
@normalyellow = "\\E[0;33m"
|
|
||||||
@red = "\\E[31m"
|
|
||||||
@normalred = "\\E[0;31m"
|
|
||||||
@clear_line = "\\E[2K\\r"
|
|
||||||
@ellipsis = " ..."
|
@ellipsis = " ..."
|
||||||
@okay = "\\E[32m)\\E[0m "
|
@okay = "%F{green})%f "
|
||||||
@warn = "! "
|
|
||||||
@error = "x "
|
@error = "x "
|
||||||
|
@done = ""
|
||||||
|
@failed = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(filename)
|
def render(filename)
|
||||||
|
@ -32,6 +22,10 @@ class Zim
|
||||||
Dir[pattern].sort.map { |filename| render(filename) }.join("\n")
|
Dir[pattern].sort.map { |filename| render(filename) }.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_escaped(filename)
|
||||||
|
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\")
|
||||||
|
end
|
||||||
|
|
||||||
def render_commented(filename)
|
def render_commented(filename)
|
||||||
render(filename).gsub(/^(?=.)/, "# ").gsub(/^$/, "#")
|
render(filename).gsub(/^(?=.)/, "# ").gsub(/^$/, "#")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue