dwmkerr / dwmkerr/git-workforest
feat: shell integration to auto-cd after commands like checkout
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 1
Description
## Summary
Investigate shell integration so that commands like `git forest checkout X` can automatically `cd` the user's shell into the checked-out tree directory.
## Problem
Currently, `git forest checkout` prints a `cd` hint that the user must copy/paste or type manually. Because the CLI runs as a child process, it cannot change the parent shell's working directory directly.
## Proposed approach
Provide a shell helper function (e.g. sourced from `eval "$(git-forest shell-init)"` in `.bashrc`/`.zshrc`) that wraps `git forest` and:
1. Runs the underlying `git-forest` command
2. Detects when a `cd` hint is emitted (or uses a structured side-channel like a temp file / env var)
3. Performs the `cd` in the parent shell
## Use case
```bash
# today
git forest checkout my-feature
# please change directory:
cd /path/to/my-feature # user must do this manually
# with shell integration
git forest checkout my-feature
# shell automatically cd's to /path/to/my-feature
```
## Things to investigate
- Best mechanism for passing the target directory back (stdout parsing, temp file, exit-code convention, etc.)
- Support for bash, zsh, and fish
- Whether this pattern should apply to other commands beyond `checkout` (e.g. `clone`)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.