worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

`wt config show` reports zsh as "Not configured" when init line is in a sourced file

Open wouter-intveld opened this issue 8 months ago • 2 comments

Summary

wt config show reports zsh: Not configured shell extension & completions even though shell integration is correctly set up and working — because the eval "$(wt config shell init zsh)" line lives in a file sourced from ~/.zshrc rather than in ~/.zshrc directly.

Reproduction

# ~/.zshrc
source $HOME/.zsh/config.d/init.zsh

# ~/.zsh/config.d/init.zsh
if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init zsh)"; fi
$ wt config show
...
zsh: Not configured shell extension & completions

Shell integration works fine in interactive sessions — type wt shows the function, wt switch changes directory correctly. The detection in wt config show is a false negative.

Expected behavior

wt config show either:

  • Detects the init line in sourced files (recursive grep / follow source directives)
  • Or shows "configured" when the shell wrapper function is actually loaded in the current session (runtime check)

Context

This pattern is common with dotfile managers (stow, chezmoi, yadm) that split shell config across multiple sourced files rather than putting everything in ~/.zshrc directly. Applies to bash as well (sourcing from ~/.bashrc).

Version

wt v0.28.2, zsh 5.9

wouter-intveld avatar Mar 06 '26 08:03 wouter-intveld

Thanks for reporting this! I was able to confirm the root cause in the codebase.

The detection in wt config show scans a hardcoded list of config files — for zsh, only ~/.zshrc (and $ZDOTDIR/.zshrc if set). It never follows source directives to check sourced files.

Code details

The detection happens in two places:

  1. scan_for_detection_details — used by wt config show to display shell status. It scans a fixed list of paths (~/.bashrc, ~/.bash_profile, ~/.profile, ~/.zshrc, fish/nushell/PowerShell paths) but never follows source/. directives.

  2. Shell::is_shell_configured — used by the shell integration warning system to determine "configured but not active" vs "not installed". Same limitation: only checks shell-specific config paths, not sourced files.

  3. configure_shell_file — used by wt config shell install to check if the init line already exists. Also only checks the target config file.

As noted in the issue, this pattern is common with dotfile managers (stow, chezmoi, yadm) that split shell config across sourced files. The same issue applies to bash (~/.bashrc sourcing other files).

I'll leave it for a maintainer to evaluate the best approach. Two potential strategies mentioned in the issue:

  • Follow source directives — parse source/. lines and recurse into referenced files (more comprehensive but fragile with variable expansion like $HOME)
  • Runtime check — spawn an interactive shell and check if the wrapper function exists, similar to how check_zsh_compinit_missing already works for compinit detection

worktrunk-bot avatar Mar 06 '26 08:03 worktrunk-bot

#2066 silences this warning in a fairly naive way

it's not perfect, but it avoids shelling out, and a quasi-parser/walker for zsh

hope that's reasonable — please reopen with cases that this doesn't fix

max-sixty avatar Apr 10 '26 20:04 max-sixty