Skip to content

fix(zsh): use global scope for typeset to support lazy loading#2769

Merged
tusharmath merged 3 commits intoantinomyhq:mainfrom
losinggeneration:fix/zsh-lazy-loading
Apr 1, 2026
Merged

fix(zsh): use global scope for typeset to support lazy loading#2769
tusharmath merged 3 commits intoantinomyhq:mainfrom
losinggeneration:fix/zsh-lazy-loading

Conversation

@losinggeneration
Copy link
Copy Markdown
Contributor

The usage of typeset within zsh's scope rules means that if the eval "$(forge zsh plugin)" is run within a function, the typeset's will be function local scoped. However, forge expects these to be globally scoped. This can be fixed by specifying typeset -g to be global instead of scoped to whatever scope it currently is.

With this fixed, it would allow lazy loading plugin managers to work, or in my case, by manually wrapping the forge initialization into a function:

forge_ai() {
if [[ -z "$_FORGE_THEME_LOADED" ]]; then
	eval "$(forge zsh theme)"
fi
}

This allows me to load forge when I want to, instead of it being always initialized on startup.

The usage of typeset within zsh's scope rules means that if the
eval "$(forge zsh plugin)" is run within a function, the typeset's will
be function local scoped. However, forge expects these to be globally
scoped. This can be fixed by specifying typeset -g to be global instead
of scoped to whatever scope it currently is.

With this fixed, it would allow lazy loading plugin managers to work, or
in my case, by manually wrapping the forge initialization into
a function:
forge_ai() {
if [[ -z "$_FORGE_PLUGIN_LOADED" ]]; then
	eval "$(forge zsh plugin)"
fi
}

This allows me to load forge when I want to, instead of it being always
initialized on startup.
@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 1, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 1, 2026

CLA assistant check
All committers have signed the CLA.

@tusharmath tusharmath enabled auto-merge (squash) April 1, 2026 17:39
@tusharmath tusharmath merged commit e69703b into antinomyhq:main Apr 1, 2026
9 checks passed
tusharmath added a commit that referenced this pull request Apr 1, 2026
@tusharmath
Copy link
Copy Markdown
Collaborator

Reverted in #2770

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants