fix: use temp file for shell wrapper CD communication#219
Merged
Conversation
…out capture The shell wrapper previously captured all stdout via $() to grep for __DAFT_CD__:/path markers. This blocked real-time output and required workarounds like CLICOLOR_FORCE and routing result() to stderr. Now the wrapper creates a temp file via mktemp, passes its path via DAFT_CD_FILE env var, and daft writes the cd target there. Stdout flows directly to the terminal, enabling real-time output during hooks and commands. Fixes #218 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 17, 2026
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
output=$(...)+ grep for__DAFT_CD__:markers) with a temp file mechanism (DAFT_CD_FILEenv var) for shell wrapper CD communicationCLICOLOR_FORCEworkaround and stderr routing forresult()messages since stdout is no longer capturedWhat changed
Rust core: New
CD_FILE_ENVconstant replacesCD_PATH_MARKER,SHELL_WRAPPER_ENV, andoutput_cd_path().cd_path()writes to the temp file instead of printing a marker.result()always prints to stdout.Shell wrappers:
__daft_wrapper()(bash/zsh/fish) creates a temp file viamktemp, passes it asDAFT_CD_FILE, runs the command with stdout flowing directly to the terminal, then reads the cd target from the file after the command finishes.Breaking change: Old shell wrappers won't work with the new binary. Users must re-source shell config after updating (
eval "$(daft shell-init bash)").Fixes #218
Test plan
mise run clippy— zero warningsmise run test-unit— 335 tests passmise run test-integration— 175 tests pass (default + gitoxide)mise run verify-man— man pages up-to-date🤖 Generated with Claude Code