Commit Graph

47 Commits

Author SHA1 Message Date
Eric Nielsen 5bcfb8cc9f
Override repository options along zmodule calls
for the same module name. Other minor fixes:
* Show skipping already installed modules with install action and `-v`.
* Consider external module dirs when calling compile action directly, by
  making sure _zimfw_source_zimrc is called first.
* Ignore return value from `zargs` with `-P`, as it's oddly returning
  123 since Zsh 5.9. Maybe related to these changes:
  67f932e7c5
2022-05-17 18:43:59 -05:00
Eric Nielsen 741bb78a04
Add `--on-pull` option to `zmodule`
Fixes #456
2022-05-07 16:31:08 -05:00
Eric Nielsen 27dcd4832e
Add `--no-submodules` option to `zmodule`
Fixes #409
2022-01-25 09:32:50 -05:00
Eric Nielsen 35e1d2ea48
Add check-dumpfile action
that removes the dumpfile if it's outdated, so it will get dumped again
when the shell starts next time. We're not using comdump because wrapped
ZLE widgets cannot or should not be identified by compdump when they
have a different name than the original one.
See https://github.com/zsh-users/zsh-syntax-highlighting/issues/851
2022-01-18 20:34:36 -05:00
Eric Nielsen 2491856a7b
Clean up and simplify code
No need to set zscriptglob in _zimfw_build_login_init anymore.
Use _zimfw_print in _zimfw_compile.
And other minor simplifications.
2022-01-10 20:41:50 -05:00
Eric Nielsen cfc955c9fd
Deprecate compile in background via login_init.zsh
Changes are:
  * Don't compile in the background anymore, only via the `zimfw` tool
    after actions where scripts can change (build, install, update)
  * Move compilation of the completion dumpfile to the completion module:
    9386a76eac/init.zsh (L10-L11)
  * Don't compile users startup scripts anymore (.zshenv, .zshrc, etc.)
  * Make output of `zimfw init` friendlier for the terminal startup
    screen when called without `-q`.

See https://github.com/romkatv/zsh-bench/pull/11#issuecomment-994979683
and https://github.com/romkatv/zsh-bench#cutting-corners

Regarding not compiling users startup scripts anymore, I'm choosing to
only compile the modules' scripts at least for the reason that compile
won't happen so ofter anymore -- it will only happen when the user calls
the `zimfw` build, install or update actions. So it makes more sense to
only compile the files that `zimfw` has control over changes...

Closes #450
2022-01-10 09:29:32 -05:00
Eric Nielsen a5fb148ccf
Force local zsh emulation options
so the code is not broken by unexpected option changes, like

    setopt RC_EXPAND_PARAM

which breaks

    print -R 'fpath=('${${_zfpaths#${~zpre}}:A}' ${fpath})'

in the _zimfw_build_init function, for example.

See #444.
2021-11-21 14:39:20 -05:00
Eric Nielsen de685e8ef3
Minor text updates in warnings, errors, and usages 2021-11-15 19:37:40 -05:00
Eric Nielsen ab613bf398
Narrow zmodule help text again
to avoid the horizontal scroll in the https://github.com/zimfw/zimfw
GitHub homepage, as GitHub made the width of the pre block further
narrower. (It's 94 characters now, was 97 before)
2021-11-08 20:05:32 -05:00
Eric Nielsen 811616cc60
Add missing `-l` in git tool print_okay
This fixes a regression introduced in commit b1edcf34d0.

Also don't use any option after `-R` just to be safe. The zshbuiltins(1)
manual states:

> Only the -e and -n flags are recognized after -R; all other arguments
> and options are printed.
2021-11-08 11:38:56 -05:00
Eric Nielsen d7229bb6bc
v1.6.0 2021-11-06 17:04:47 -05:00
Eric Nielsen 4259e64d22
Update init action to also install new modules
so users don't get a "Not installed" error when they add a new module to
.zimrc and forget to run `zimfw install` after that.

See #440
2021-10-26 11:15:40 -05:00
Eric Nielsen de7d2b131f
More verbose output in install and update actions
listing modules that are frozen or exernal.

Also be less colorful. And some other minor fixes: allow autoloading a
function name that starts with `-`, and add required quotes around
command subsitution (otherwise words are split).
2021-09-29 21:22:28 -05:00
Eric Nielsen b1edcf34d0
Use `print -l` to print multiple lines
and also remove extra quotes. Still only leave redundant quotes in

    zstyle -s 'context' style 'name'

as that's kind of a convention already.
2021-09-23 14:29:40 -05:00
Eric Nielsen 6ca4690edc
Further improve handling of external modules
Fix computing the list of unused modules by using the full `_zdirs`
instead of just the `_zmodules` names. The fixed code was even simpler
and cleaner, which makes it even more satisfying.  :- )

Show "not found" instead of "not installed" error when an external
module dir does not exist, since we don't install external modules.
2021-09-23 11:44:31 -05:00
Eric Nielsen 92e6d6b74b
Don't output warnings in quiet mode
For sake of simplicity, and also to distinguish warnings from errors.
So now we have:
  * errors: output to stderr, are **not** silenced with `-q`
  * warnings: output to stderr, are silenced with `-q`
  * info: output to stdout, are silenced with `-q`
  * solicited output (like help, info, or list): output to stdout, does
    not make sense to be silenced with `-q`

We also only have warning in 3 situations so far...  :- )
2021-09-21 16:47:04 -05:00
Eric Nielsen 9a67adfe3b
Update zimfw help text to be more detailed
and add more comments to the code to also hopefully make it clearer.
2021-09-21 08:27:56 -05:00
Eric Nielsen e097e6bf71
Add list action, don't run tool on external module
Using the `list` action with `-v` shows all current details for the
existing modules.
Don't try to install or update external modules, since they have an
absolute path instead of a valid URL.
2021-09-19 13:37:13 -05:00
Eric Nielsen c51898fef0
v1.5.0 2021-08-10 09:56:25 -05:00
Eric Nielsen 7d43589843
Add zstyle to set default zmodule tool
and also simplify code by setting multiple variables at once. This
should make the resulting script a tiny bit smaller, while not
compromising on legibility.
2021-07-11 15:58:15 -05:00
Eric Nielsen 2c8f8e348e
Update help and error messages
and bring back the help message for -z|--frozen that was deleted
accidentally.
2021-07-01 18:08:25 -05:00
Eric Nielsen cffd456556
Add new degit tool \o/
and rename previous to git.

Tools allow for different install and update scripts. The git tool does
what the previous implementation did (installs and updates using the git
client). The new tool installs and updates with the GitHub API, not
using the git client, but using curl/wget and tar instead.

Closes #373
2021-04-07 17:54:47 -05:00
Eric Nielsen 65783e61ed
Use 2 as exit code for usage errors
See https://tldp.org/LDP/abs/html/exitcodes.html
2021-03-19 17:13:21 -05:00
Eric Nielsen 3e06f0aa99
v1.4.0 2021-01-07 13:41:35 -05:00
Eric Nielsen 3567694a0f
Use repository's default branch
instead of hardcoding the default to `master`, when no branch is
specified in `zmodule`.
Fixes #422
2021-01-02 19:09:52 -05:00
Eric Nielsen ccace0ca74
Clean compiled files from absolute path modules
We were already compiling at these paths, but not cleaning the compiled
files.
Fixes #399
2020-07-31 21:03:47 -05:00
Eric Nielsen 9b02b41f47
Add `-c|--cmd` option to `zmodule`
so freely defined commands can be executed.

Fixes #405
2020-07-02 17:16:44 -05:00
Eric Nielsen 99e6b31891
Init and compile local modules in their directories
instead of requiring that they're installed inside ZIM_HOME.

Fixes #399
2020-06-09 21:34:21 -05:00
Eric Nielsen 853e5a767c
v1.2.0 2020-05-17 10:30:14 -05:00
Eric Nielsen 8724686e85
Don't depend on `cmp` and `xargs`
as they requires busybox or diffutils and findutils.
Use `cksum` and `zargs` instead.

Fixes #393
2020-05-16 20:22:22 -05:00
Eric Nielsen 7e369ef9cf
Update zmodule usage text
Hopefully the README.md will look aesthetically better with a pre block
instead of switching between text and `code`.
2020-05-02 18:47:38 -05:00
Eric Nielsen 1341afe525
Optional async check for latest version
every 30 days, storing it in a .latest_version file.

Also allow disabling this with:

    zstyle ':zim' disable-version-check yes
2020-01-16 11:30:09 -05:00
Eric Nielsen 7fdf65c58f
Don't call _zimfw_build_login_init after upgrade
as it was being used to update the login_init.zsh script. BUT the
function mentioned, which updates that script, would only be updated
after zimfw.zsh is sourced again, so no point in trying to call it at
this point.
2020-01-13 15:00:09 -05:00
Eric Nielsen be2be83560
Check the latest version using `git ls-remote`
which is being used to list the latest tag starting with `v`.
Print a warning if it's different than the current version being used.
2020-01-13 13:14:31 -05:00
Eric Nielsen dab4b87a29
Add help and version actions 2020-01-13 12:24:43 -05:00
Eric Nielsen ee99fe8a36
Add `-v` (verbose) option
so the normal output is focused on the given action, and output for
additional steps perfomed after the given action is only shown in
verbose mode.

Also, the output of wget is only shown in verbose mode. This is because
wget always shows some output (to stderr) even when there are no errors.
See https://serverfault.com/q/70889/302338

This should give a friendlier output.
See #360
2020-01-11 16:34:36 -05:00
Eric Nielsen 424526ebee
Refactor: extract _zimfw_print function 2020-01-09 07:13:31 -05:00
Eric Nielsen dd84c41ae5
v1.0.0
Changes:
*  Reduce the Zim "core" to a single file
*  Simplify installation with an installation script (Closes #182)
*  Put the configuration into .zshrc instead of a separate .zimrc
   (Closes #288)
*  Do not support themes that require promptinit (See #325)
*  Generate a static script that does autoload the functions and source
   the modules

This version is not backwards-compatible with previous versions, so a
new installation of Zim is required.
2020-01-02 13:13:12 -05:00
Eric Nielsen 0b19b2f89a
Update README.md and zimfw output
due to latest changes on how Zim works.
2020-01-02 12:58:04 -05:00
Eric Nielsen aade4704b1
Generate login_init.zsh file
So we can have the following code in the zlogin template:

    source ${ZIM_HOME}/login_init.zsh -q &!

instead of depending on the zimfw function there. This allows fixing the
issue were a non-interactive login shell currently yields:

    command not found: zimfw.

To fully fix the issue, we also need a new zshenv template containing:

    ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim

Templates will be updated in the install script.
2020-01-02 12:58:04 -05:00
Eric Nielsen 93bbc35634
Use ASCII characters only
we want to be a universal Zsh framework, and send the message that
"less is less"!  ;- )

Don't indent done and failed messages with an indicator, at the end of
actions, to differentiate them from intermediate okay and error messages.
2020-01-02 12:58:03 -05:00
Eric Nielsen 7139771ec6
Rename zimfw action clean-modules to uninstall
and have `zimfw clean` only do `clean-compiled` and `clean-dumpfile`.
Semantically, it makes much more sense because we will be then cleaning
temporary files that are later compiled/generated again, which is not
the case for a module (which we'll be uninstalling now instead of
cleaning).
2020-01-02 12:58:03 -05:00
Eric Nielsen cec82ea0e5
Add zimfw init action for a quick build
Having to manually do `zimfw build` every time after you edit your
.zimrc file is boring. So by having the following in .zshrc before
sourcing init.zsh will do a quick build automatically when needed:

    if [[ ~/.zim/init.zsh -ot ~/.zimrc ]]; then
      source ~/.zim/zimfw.zsh init -q
    fi
2020-01-02 12:58:02 -05:00
Eric Nielsen c47c4fc08b
Compile also after upgrade, add ZIM_HOME to info
We want to recompile zimfw.zsh if it changes.
ZIM_HOME is not required to be set beforehand anymore, so let's give the
users the variable info back.
2020-01-02 12:58:02 -05:00
Eric Nielsen a227f134a5
Source .zimrc twice when installing/updating
Once before installing/updating to prepare _zmodule_xargs, and once
after modules are updated, so functions and scripts can be found inside
them. Installation of Zim from scratch was failing because all modules
are empty at first.
2020-01-02 12:58:01 -05:00
Eric Nielsen dfe35e1bfa
Generate static init.zsh script \o/
to autoloads the functions and sources the scripts, instead of executing
zimfw during startup, and having it always figuring out what do to on
the fly.

This takes out the worry about zimfw interfering with the startup time,
and allows room to add more features to it. So, zstyle was replaced by a
custom zmodule function to define the modules, with the extra ability of
allowing users to set custom fpath paths, autoloaded functions and
sourced scripts per module.
2020-01-02 12:58:01 -05:00
Eric Nielsen 1980ca091d
Zim script in a single file \o/
Also moved the templates out of this repository, and into the
zimfw/install repo.

This is a second big change after introducing the plugin mechanism. This
makes installation and upgrading of Zim straightforward. Maybe the most
important aspect of having the script in a single file is not having to
manage "git repos inside git repos" (see #297), since the single file
exists by itself and is not version-controlled (with git).

I've implemented a two-stage sourcing of the file, so most of the file
is only sourced when needed (namely when calling `zimfw` with any action
other than `login-init`). The two-stage process is designed to avoid
compromising the startup speed, which is our top priority.

In an effort to help making the script maintainable, I've broken it into
small ERB templates. This also adds the ability to pre-process the Zsh
code with Ruby code. To build the script, use `make`.
2020-01-02 12:58:01 -05:00