Commit Graph

107 Commits

Author SHA1 Message Date
Eric Nielsen 2e9256a567
Add new mkdir tool to generate empty modules
This will allow creating modules that contain only externally generated
files. For example, this is how I currently use it to generate modules
for code that is supposed to be eval'ed:

    zmodule-eval() {
      local -r zcommand=${${=1}[1]} ztarget=${1//[^[:alnum:]]/-}.zsh
      zmodule custom-${zcommand} --use mkdir --if-command ${zcommand} \
          --cmd "if [[ ! {}/${ztarget} -nt \${commands[${zcommand}]} ]]; then ${1} >! {}/${ztarget}; zcompile -UR {}/${ztarget}; fi" \
          --source ${ztarget}
    }
    zmodule-eval 'starship init zsh'
    unfunction zmodule-eval
2024-02-16 20:41:29 -05:00
Eric Nielsen 8bec2f7549
Add `--if-command` option to `zmodule` 2024-01-22 21:36:17 -05:00
Eric Nielsen 26151d2f54
Remove prompt expansion from print statements
and replace the foreground color and bold expansions by ANSI escape
codes. This should make the print calls now safe and no expansion at all
should happen as we're using `-R` -- unless the `-e` flag is given.
Fixes #521. Closes #522
2023-09-16 13:21:14 -05:00
Eric Nielsen d33d632ec1
Use `--sort=-v:refname` in _zimfw_check_version
to sort tags, instead of using Zsh's `(On)`. The tags will come sorted
already.
2023-09-15 19:55:43 -05:00
Eric Nielsen 49386cad6d
Make forced check-version asynchronous (again)
as it was before a34b8dab64.
Don't make zimfw hang in the foreground waiting for git to connect to
GitHub, mainly because the waiting can take too long in case of
connection issues or no network. Also set git timeout to 30 seconds so
background check also does hang for too long, just it case.

Fixes #514
2023-06-16 20:24:33 -05:00
Eric Nielsen 0566b9b8a3
Use _zimfw_print 2023-06-15 09:33:14 -05:00
alesandar f9648e07a9
Handle module root directories without write permission
Closes #513. Fixes #512
2023-06-15 09:26:37 -05:00
Eric Nielsen f93e43e8a5
Tools run in a subshell 2023-03-31 20:34:26 -05:00
Eric Nielsen 67de6ec25b
Don't resolve symlinks when building init.zsh
So init.zsh is consistent after symlinks change to point to something
else. See zimfw/completion#15
2023-03-30 08:38:12 -05:00
Eric Nielsen ee93f7944f
Don't use a new shell to run tool anymore
This was needed when we were using xargs, but we're already using zargs
instead for quite some time. Pro is that now common functions are reused
instead of repeated. Con (or change) is that due to that reuse, and in
favor of simplification, the warning for a module with git submodules in
degit is in a separate line from a separate print call now.

Also fix regressions from recent commits:
- Need to call _zimfw_source_zimrc twice with 1 and 2 flags instead of
  with flag 3, since flag 2 must be used after module is installed or
  updated.
- Need to call _zimfw_print_okay from the function that handles on-pull,
  since we want to include the on-pull output in verbose mode. This
  function was called just `handle` before, now it's called
  _zimfw_pull_print_okay.

Still need to figure out how to return a final error code from
_zimfw_run_tool_action.
2023-03-28 07:56:37 -05:00
Eric Nielsen 903e0e5249
Add check and rename version-check to check-version
actions. Return 4 if there's a zimfw update from check-version. Don't
return a specific error code if there are module updates from check, as
it uses zargs to check all and each check runs in a separate shell. Need
to figure out how to propagate all that to a final error code.

See #503
2023-03-26 09:34:07 -05:00
Eric Nielsen b7b33f3786
Also output LANG LC_* parameters in info action 2023-03-24 09:46:44 -05:00
Eric Nielsen a34b8dab64
Add version-check action
And don't run the dumping of the .latest_version file in
_zimfw_version_check in the background (with `&!`) anymore.

See #503
2023-03-24 08:44:52 -05:00
Eric Nielsen 6a24459de9
Deprecate check-dumpfile action
The completion module alone will handle checking the dumpfile.
See https://github.com/zimfw/completion/pull/12
2023-02-25 19:03:37 -05:00
Eric Nielsen f71bff5418
Quote path names in init.zsh
to properly handle path names with spaces.
Fixes #497
2023-02-16 07:51:30 -05:00
Eric Nielsen d10d7c627c
Revert "Further improve check-dumpfile action accuracy"
This reverts commit e47eaae2e4.
2023-02-16 07:51:30 -05:00
Eric Nielsen e47eaae2e4
Further improve check-dumpfile action accuracy
Previous change fixed the old dumpfile vs. new dumpfile check, but
removed an existing (but flawled) old Zim fpath vs. new Zim fpath check.
We should be doing both checks the right way now.
2023-02-06 19:19:15 -05:00
Eric Nielsen a434fda508
More accurate check-dumpfile action
by using the `_zim_dumpfile_fpath` variable set by the completion module
[here](33737e8c15/init.zsh (L11))
right before `compinit` is run.
2023-02-03 18:56:16 -05:00
Eric Nielsen 281cde57f7
v1.11.0 2022-12-18 16:09:04 -05:00
Eric Nielsen e54958b91c
Allow customizing .zimrc file path
with the ZIM_CONFIG_FILE environment variable.
Fixes #479.
2022-10-23 19:34:14 -05:00
Eric Nielsen 3959a7f4e0
Add `--if` option to `zmodule`
Fixes #355
2022-10-06 19:52:57 -05:00
Eric Nielsen 8a9d63c522
Fix quoting string in glob
so it does not get expanded as a glob itself, if it contains special
characters.
2022-09-28 19:42:05 -05:00
Eric Nielsen 238da94b54
v1.10.0 2022-09-27 17:45:16 -05:00
Eric Nielsen 05b8e0cdf2
Add `--root` option to `zmodule`
which makes it straighforward to use repositories that contain multiple
modules, like sorin-ionescu/prezto or ohmyzsh/ohmyzsh.
2022-09-26 20:33:49 -05:00
Eric Nielsen 887bfd6a03
Update info action output and update README.md
Show the value of some relevant environment variables instead of calling
uname, which might show private information like the host name.

Other minor fixes regarding output.
2022-08-02 12:49:09 -05:00
Eric Nielsen a620953556
v1.9.1 2022-05-24 16:25:32 -05:00
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 016e498bd6
Also work when _zim_fpath is not set
when doing `zimfw check-dumpfile`, otherwise it won't work until init.zsh
is rebuilt, because it's a newly introduced variable.
2022-01-24 18:58:28 -05:00
Eric Nielsen ac2843d8c8
Simplify check-dumpfile to do the same as compinit
first because simpler is usually better, and second because we cannot
always guarantee that the .latest_comp file, which was holding the list
of all completion functions, is consistently in sync with the dumpfile
that is generated afterwards.
2022-01-18 20:51:11 -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 92bfa96993
Further clean up and simplify code
@startup_files_glob is not used anymore.
2022-01-11 11:29:47 -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 1d5c0c18d1
Initalization options are all auto or all manual
in `zmodule`, since there's no way to unset a default value to "nothing".
2021-09-26 19:47:44 -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 7deda9c7f4
Show a more informative error when running zmodule
from the shell. This means getting

    zmodule: Must be called from ${ZDOTDIR:-${HOME}}/.zimrc

and the full zmodule usage, instead of getting

    zsh: command not found: zmodule

Fixes #430
2021-09-20 21:21:27 -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 476bb6b320
Fix warning when WARN_CREATE_GLOBAL is set
and ZIM_HOME is not. It can be reproduced with:

    unset ZIM_HOME
    setopt WARN_CREATE_GLOBAL
    zimfw info

and the warning is:

    zimfw.zsh:33: scalar parameter ZIM_HOME created globally in function zimfw
2021-08-31 18:42:30 -05:00