Issue #632: the pager machinery already recognized -n/--no-pager
globally and .zinit-pager already honors OPTS[opt_-n,--no-pager], but
self-update rejected the flag with "Incorrect options given". Allow it
so the commit list can be printed straight to the terminal; help and
error output pick the flag up automatically from the option map. Also
offer the flag in the _zinit completion.
Closes#632
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
Drop the anonymous-function indirection in .zinit-cd-quiet and pass --,
collapse the duplicated landing cd in .zinit-restore-dir, and convert the
six remaining hand-rolled copies of the idiom in zinit-install.zsh to the
named helper.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
${ICE[atinit#!]} subscripts a literal "atinit#!" key and expands to
nothing, so atinit'!...' never ran for as"command" plugins.
${ICE[atinit]#1} stripped a leading "1" instead of "!", leaving the bang
in the evaluated code. Both now strip the prefix they meant to.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
The ___moved guard skipped the restore whenever zinit did not cd
itself, so an ice body that cds under nocd stranded the shell wherever
the plugin left it. Make the restore unconditional and give
.zinit-restore-dir a fast path so the case where nothing moved stays
free.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
Every ice that runs code inside a plugin or snippet directory (atinit,
atload, multisrc, atclone, atpull, ps-on-unload) saved and restored $PWD
around the temporary cd, but never $OLDPWD. `cd -q' suppresses chpwd
hooks and `noautopushd' suppresses the directory stack, but neither
suppresses $OLDPWD, so the cd back left it pointing at the directory
just visited. Opening a new shell and pressing `cd -' jumped into a
zinit plugin directory without the user ever having gone there.
Add .zinit-cd-quiet/.zinit-restore-dir, which return to the original
$PWD by cd'ing through the original $OLDPWD for real. A plain $OLDPWD
assignment is not enough: `cd -' reads zsh's internal previous-directory
state, not the parameter, so assigning it leaves the parameter looking
correct while `cd -' still navigates to the plugin directory. When the
original $OLDPWD is empty or has since been deleted, bounce through
$PWD instead, which degrades `cd -' to a harmless no-op rather than
emitting an error and leaking the plugin directory anyway.
Also gate the restore on the cd having actually happened. It ran
unconditionally, so with the nocd ice -- where no cd takes place -- the
no-op cd back to $PWD still set OLDPWD=$PWD, silently discarding the
user's real previous directory.
Sites already protected by a real subshell, and the user-facing `zinit
cd' and `zinit create' commands that are meant to leave you in the
target directory, are left untouched.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
Resolve ZINIT[...] settings from `zstyle ':zinit:config' <attr>` before
the BIN_DIR/HOME_DIR/derived-dir logic runs. The attribute name is the
hash field lowercased with `_` replaced by `-` (HOME_DIR -> home-dir).
An explicitly-set ZINIT[KEY] always wins over zstyle, which wins over
the built-in default; fully backward-compatible.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
* Refactored 'configure' and 'make' ices
* New 'build' ice sets 'configure' and 'make ices if no flags are needed.
* New 'cmake' ice will build/install using 'cmake'
* Delete command now handles programs using 'make' and 'cmake' ices
* Setting `$ZINIT[DEBUG]` enables debug logging (i.e., `+zi-log "{dbg} message ..."`)
- Rename all instances of +zinit-message to +zi-log
- Maintain compatibility with community plugins/annexes by forwarding +zinit-message calls to +zi-log
Signed-off-by: Doster, Vladislav <mvdoster@gmail.com>
Issues addressed:
1. Confusing and unintuitive command names
Currently, two commands `loaded` and `list` will list installed
plugins and a single command `ls` lists installed snippets. The namea
don't make much sense or give context to their behavior, nor does
having two commands with identical behavior.
This PR removes the three commands in favor of two new commands
`list-snippets` and `list-plugins`. The names align with the action they
perform.
2. Uninformative output
Current output is hard to grok.
This PR cleans up the output format and uses color to help convey
information.
3. Incorrect
Output does not account for various situations with the only way to
fix is to reload Zsh session which would not always fix it. See images
below for the aforementioned situations.
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
The useful %x prompt expansion can be used to get path to the executed script:
0=${(%):-%x}
It is always the correct, expected value, even for autoloaded functions. However,
it currently doesn't work with Zinit special fpath-pollution free autoload.
This patch fixes this.
This reverts commit b979847bd4, reversing
changes made to da924a21a1.
I (@vladdoster) accidentally merged this into the wrong repository. Apologies for the lack of due diligence.
This can be used to overwrite `as'null'`, which would otherwise not trigger
completion detection and installation.
It will override the `nocompletions` ice when both are specified (e.g., using
the default ice annex).
The scheduler is called in 10 seconds intervals when no tasks are present to lower CPU usage.
Co-authored-by: vladislav doster <10052309+vladdoster@users.noreply.github.com>