Appearance
daft shell-init
Generate shell wrapper functions for daft commands
Description
Generate shell wrapper functions that enable automatic cd into new worktrees.
By default, when daft commands create or switch to a worktree, the process changes directory but the parent shell remains in the original directory. These wrappers solve this by reading the CD target from a temp file and using the shell's builtin cd.
Add to your shell config:
bash
# Bash (~/.bashrc)
eval "$(daft shell-init bash)"
# Zsh (~/.zshrc)
eval "$(daft shell-init zsh)"
# Fish (~/.config/fish/config.fish)
daft shell-init fish | sourceWith short aliases (gwco, gwcob, etc.):
bash
eval "$(daft shell-init bash --aliases)"The generated output includes:
- Shell wrapper functions for all
git-worktree-*commands - A
gitwrapper that interceptsgit worktree-*subcommands - A
daftwrapper that interceptsdaft worktree-*subcommands - Shortcut wrappers for all shortcut styles (gwtco, gwco, gclone, etc.)
- Default-branch shortcuts (gwtcm, gwtcbm, gwcobd, gcbdw)
- Shell completions for all commands
Usage
daft shell-init <SHELL> [OPTIONS]Arguments
| Argument | Description | Required |
|---|---|---|
<SHELL> | Target shell (bash, zsh, fish) | Yes |
Options
| Option | Description | Default |
|---|---|---|
--aliases | Include short aliases (gwco, gwcob, etc.) |
Global Options
| Option | Description |
|---|---|
-h, --help | Print help information |
-V, --version | Print version information |
How It Works
The wrappers use a temp file mechanism for shell cd:
- Before running a daft command, the wrapper creates a temp file
- The temp file path is passed via the
DAFT_CD_FILEenvironment variable - The daft command writes the target directory to this file
- After the command finishes, the wrapper reads the file and calls
cd - The temp file is cleaned up
This approach keeps stdout clean for normal command output.