worktrunk 0.37.1

A CLI for Git worktree management, designed for parallel AI agent workflows
Documentation
---
source: tests/integration_tests/init.rs
info:
  program: wt
  args:
    - config
    - shell
    - init
    - fish
  env:
    APPDATA: "[TEST_CONFIG_HOME]"
    CLICOLOR_FORCE: "1"
    COLUMNS: "500"
    GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
    GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
    GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
    GIT_CONFIG_SYSTEM: /dev/null
    GIT_EDITOR: ""
    GIT_TERMINAL_PROMPT: "0"
    HOME: "[TEST_HOME]"
    LANG: C
    LC_ALL: C
    MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
    NO_COLOR: ""
    OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
    PATH: "[PATH]"
    PSModulePath: ""
    RUST_LOG: warn
    SHELL: ""
    TERM: alacritty
    USERPROFILE: "[TEST_HOME]"
    WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
    WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
    WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
    WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
    WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
    WORKTRUNK_TEST_EPOCH: "1735776000"
    WORKTRUNK_TEST_NUSHELL_ENV: "0"
    WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
    WORKTRUNK_TEST_POWERSHELL_ENV: "0"
    WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
    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 with split directive passing.
# Creates two temp files: one for cd (raw path) and one for exec (shell).
# 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)
    set -l exec_file (mktemp)

    # --source: use cargo run (builds from source)
    if test $use_source = true
        env WORKTRUNK_DIRECTIVE_CD_FILE=$cd_file WORKTRUNK_DIRECTIVE_EXEC_FILE=$exec_file \
            cargo run --bin wt --quiet -- $args
    else
        env WORKTRUNK_DIRECTIVE_CD_FILE=$cd_file WORKTRUNK_DIRECTIVE_EXEC_FILE=$exec_file \
            $WORKTRUNK_BIN $args
    end
    set -l exit_code $status

    # 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 trim < "$cd_file")
        cd -- "$target"
        set -l cd_exit $status
        if test $exit_code -eq 0
            set exit_code $cd_exit
        end
    end

    # exec file holds arbitrary shell (e.g. from --execute)
    if test -s "$exec_file"
        set -l directive (string collect < "$exec_file")
        eval $directive
        set -l src_exit $status
        if test $exit_code -eq 0
            set exit_code $src_exit
        end
    end

    command rm -f "$cd_file" "$exec_file"
    return $exit_code
end

# Completions are in ~/.config/fish/completions/wt.fish (installed by `wt config shell install`)

----- stderr -----