feat: add setup_terminal addon for automatic shell environment configuration by mtxr · Pull Request #8086 · mitmproxy/mitmproxy

Description

Implements terminal setup endpoints for automatic shell environment configuration, similar to HTTP Toolkit. Users can now easily configure their proxy settings by running a single command.

I personally prefer mitmproxy over http toolkit, but to be honest what I missed the most was the auto setup script. I'm used to call my local proxy setup script like this source ./setup-term-proxy 8000 which does basically what is in this PR.

What's New

  • New addon: setup_terminal that provides setup endpoints on any proxy address/port
  • 4 endpoints:
    • /setup - Returns JSON with proxy configuration and certificate paths
    • /setup.sh - Bash script with environment variables (works with sh, bash, zsh, ksh)
    • /setup.fish - Fish shell script
    • /setup.ps1 - PowerShell script with Stop-Intercepting function

Usage

# Bash/Zsh/Ksh
eval "$(curl -sS http://127.0.0.1:8080/setup.sh)"

# Fish
source (curl -sS http://127.0.0.1:8080/setup.fish | psub)

# PowerShell
. (curl -Uri http://127.0.0.1:8080/setup.ps1).Content

What Gets Configured

  • Proxy variables: HTTP_PROXY, HTTPS_PROXY, WS_PROXY, WSS_PROXY, npm_config_proxy, etc.
  • Certificate paths: SSL_CERT_FILE, NODE_EXTRA_CA_CERTS, GIT_SSL_CAINFO, CARGO_HTTP_CAINFO, etc.
  • Shell aliases: winpty compatibility on Windows (just like http toolkit)

Documentation

Added docs/src/content/howto/automatic-shell-setup.md with:

  • Quick start for each shell
  • Available endpoints documentation
  • Environment variables reference
  • Programmatic access examples

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.