:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(devenv): auto-load phw on flox activate (#58117)
Georges-Antoine Assif5094600c354
diff --git a/.flox/env/manifest.toml b/.flox/env/manifest.tomlindex 3dec28afe24c..b4f3a6779c11 100644--- a/.flox/env/manifest.toml+++ b/.flox/env/manifest.toml@@ -109,6 +109,8 @@ bash = '''source $UV_PROJECT_ENVIRONMENT/bin/activate# Source hogli bash completions[ -f "$FLOX_ENV_CACHE/completions/hogli.bash" ] && source "$FLOX_ENV_CACHE/completions/hogli.bash"+ # Load phw worktree helper+ [ -f "$FLOX_ENV_PROJECT/bin/phw" ] && source "$FLOX_ENV_PROJECT/bin/phw" >/dev/null'''zsh = '''if [[ -f "$HOME/.zshrc" ]]; then@@ -134,6 +136,8 @@ zsh = '''# Add hogli completions to zsh[[ -f "$FLOX_ENV_CACHE/completions/_hogli" ]] && fpath=("$FLOX_ENV_CACHE/completions" $fpath)autoload -Uz compinit && compinit -i+ # Load phw worktree helper+ [[ -f "$FLOX_ENV_PROJECT/bin/phw" ]] && source "$FLOX_ENV_PROJECT/bin/phw" >/dev/null'''fish = '''set -e GOROOTdiff --git a/bin/phw b/bin/phwindex 53f3a257c4cd..55f4a6c553ae 100644--- a/bin/phw+++ b/bin/phw@@ -2,16 +2,9 @@# PostHog Worktree wrapper function installer# Source this file in your shell profile to use the phw function-# Get the directory of this script when being sourced-_phw_script_dir=""-if [ -n "${BASH_SOURCE[0]:-}" ]; then- _phw_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"-elif [ -n "${ZSH_VERSION:-}" ]; then- _phw_script_dir="$(cd "$(dirname "$0")" && pwd)"-fi--# Source utility functions for consistent error handling-source "$_phw_script_dir/helpers/_utils.sh" 2>/dev/null || {+# phw is sourced from the flox activate hook, so $FLOX_ENV_PROJECT points+# to the repo root that owns this script.+source "$FLOX_ENV_PROJECT/bin/helpers/_utils.sh" 2>/dev/null || {# Fallback error function if utils not availableerror() { echo "Error: $*" >&2; }fatal() { error "$*"; return 1; }@@ -53,7 +46,7 @@ _switch_to_worktree() {}phw() {- local script_path="${_phw_script_dir}/posthog-worktree"+ local script_path="$FLOX_ENV_PROJECT/bin/posthog-worktree"local command="$1"local branch="$2"@@ -197,4 +190,4 @@ elif [ -n "$ZSH_VERSION" ]; thenfifi-echo "PostHog worktree helper loaded. Use 'phw' command."\ No newline at end of file+echo "PostHog worktree helper loaded. Use 'phw' command."diff --git a/bin/posthog-worktree b/bin/posthog-worktreeindex 5292a683280a..9cfadd07eaa3 100755--- a/bin/posthog-worktree+++ b/bin/posthog-worktree@@ -348,9 +348,6 @@ setup_worktree_environment() {echo "To start working:"print_color blue " cd ${worktree_path}"print_color blue " bin/start"- echo ""- print_color yellow "💡 Tip: For auto-cd functionality, add this to your shell profile:"- print_color yellow " source $(dirname "$0")/phw"}# Function to list all worktrees@@ -438,8 +435,5 @@ case "$COMMAND" inecho " - Set POSTHOG_WORKTREE_BASE to customize worktree location"echo " - Default: ~/.worktrees/posthog"echo ""- print_color yellow "💡 For auto-cd functionality, add to ~/.zshrc or ~/.bashrc:"- print_color yellow " source $(dirname "$0")/phw"- print_color yellow " Then use 'phw' instead of '$0'";;-esac\ No newline at end of file+esacdiff --git a/docs/published/handbook/engineering/flox-multi-instance-workflow.md b/docs/published/handbook/engineering/flox-multi-instance-workflow.mdindex b8a86bb989eb..d37a5812d656 100644--- a/docs/published/handbook/engineering/flox-multi-instance-workflow.md+++ b/docs/published/handbook/engineering/flox-multi-instance-workflow.md@@ -58,9 +58,6 @@ brew install direnv gh jq# Add direnv hook to your shell (~/.zshrc or ~/.bashrc)eval "$(direnv hook zsh)" # or bash-# Add the phw function for auto-cd functionality-echo 'source ~/dev/posthog/posthog/bin/phw' >> ~/.zshrc # or ~/.bashrc-# Reload your shellsource ~/.zshrc # or ~/.bashrc@@ -352,12 +349,11 @@ flox activate### phw command not found-```bash-# Make sure you've sourced the phw script-source ~/dev/posthog/posthog/bin/phw+Make sure the Flox environment is activated:-# Add it permanently to your shell profile-echo 'source ~/dev/posthog/posthog/bin/phw' >> ~/.zshrc+```bash+cd ~/dev/posthog/posthog+flox activate```### Dependencies out of sync@@ -401,18 +397,20 @@ git worktree pruneFor a complete one-time setup, run:```bash-# For zsh users+# For zsh users (replace ~/dev/posthog/posthog with your repo path)brew install direnv gh jq && \echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc && \-echo 'source ~/dev/posthog/posthog/bin/phw' >> ~/.zshrc && \source ~/.zshrc && \+cd ~/dev/posthog/posthog && \+flox activate -- true && \echo "✅ Setup complete! You can now use 'phw' commands."-# For bash users+# For bash users (replace ~/dev/posthog/posthog with your repo path)brew install direnv gh jq && \echo 'eval "$(direnv hook bash)"' >> ~/.bashrc && \-echo 'source ~/dev/posthog/posthog/bin/phw' >> ~/.bashrc && \source ~/.bashrc && \+cd ~/dev/posthog/posthog && \+flox activate -- true && \echo "✅ Setup complete! You can now use 'phw' commands."```