Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
---
source: tests/integration_tests/init.rs
info:
program: wt
args:
- config
- shell
- init
- fish
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"
CLICOLOR_FORCE: "1"
COLUMNS: "500"
GIT_ALLOW_PROTOCOL: file
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_AUTHOR_EMAIL: [email protected]
GIT_AUTHOR_NAME: Test User
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_EMAIL: [email protected]
GIT_COMMITTER_NAME: Test User
GIT_CONFIG_COUNT: "2"
GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
GIT_CONFIG_KEY_0: user.useConfigOnly
GIT_CONFIG_KEY_1: rerere.enabled
GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
GIT_CONFIG_VALUE_0: "true"
GIT_CONFIG_VALUE_1: "false"
GIT_TERMINAL_PROMPT: "0"
HOME: "[TEST_HOME]"
LANG: C
LC_ALL: C
LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
PATH: "[PATH]"
TERM: alacritty
USERPROFILE: "[TEST_HOME]"
WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
WORKTRUNK_TEST_BASH_INSTALLED: "0"
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
WORKTRUNK_TEST_CODEX_INSTALLED: "0"
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_FISH_INSTALLED: "0"
WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_PARENT_SHELL: ""
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
---
success: true
exit_code: 0
----- stdout -----
# worktrunk shell integration for fish
#
# This is the full function definition, output by `wt config shell init fish`.
# It's sourced at runtime by the wrapper in ~/.config/fish/functions/wt.fish.
# Override wt command so it can change the parent shell's directory.
# WORKTRUNK_BIN can override the binary path (for testing dev builds).
function wt
set -l use_source false
set -l args
for arg in $argv
if test "$arg" = "--source"; set use_source true; else; set -a args $arg; end
end
test -n "$WORKTRUNK_BIN"; or set -l WORKTRUNK_BIN (type -P wt 2>/dev/null)
if test -z "$WORKTRUNK_BIN"
echo "wt: command not found" >&2
return 127
end
set -l cd_file (mktemp)
# Older fish unwinds only the function that directly launched an interrupted
# child. This boundary lets ordinary cleanup run before its caller continues.
# Newer fish unwinds the whole input line; postexec owns cleanup in that case.
set -l cleanup_function _wt_cleanup_(string replace -a / _ -- "$cd_file")
set -l run_function "$cleanup_function"_run
function $run_function
command $argv
end
function $cleanup_function --on-event fish_postexec --inherit-variable cd_file --inherit-variable cleanup_function --inherit-variable run_function
set -l cd_exit 0
# cd file holds a raw path — read with fish builtin (no cat subprocess,
# safe even if CWD was removed by worktree removal).
if test -s "$cd_file"
set -l target (string collect < "$cd_file")
# `builtin cd` bypasses any user `cd` override (e.g. the zoxide.fish
# plugin replaces `cd` with a query function that mishandles the `--`
# separator). Matches the bash/zsh wrappers. (#3159)
builtin cd -- "$target"
set cd_exit $status
end
command rm -f "$cd_file"
functions -e $cleanup_function $run_function
return $cd_exit
end
# --source: use cargo run (builds from source)
if test $use_source = true
$run_function env WORKTRUNK_DIRECTIVE_CD_FILE=$cd_file \
cargo run --bin wt --quiet -- $args
else
$run_function env WORKTRUNK_DIRECTIVE_CD_FILE=$cd_file \
$WORKTRUNK_BIN $args
end
set -l exit_code $status
$cleanup_function
set -l cd_exit $status
if test $exit_code -eq 0
set exit_code $cd_exit
end
return $exit_code
end
# Completions are in ~/.config/fish/completions/wt.fish (installed by `wt config shell install`)
----- stderr -----