fix: pm3 command for mode switching without re-sourcing venv

source activate once, then pm3/pm3 sim/pm3 sniff/pm3 all to launch
REPL with appropriate imports. Uses python -i for reliable startup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
michael
2026-03-18 21:05:00 -07:00
parent c1ab980036
commit f294aba9ef

View File

@@ -1,21 +1,19 @@
# pm3py venv activation with mode-based auto-imports. # pm3py venv activation.
# Usage: source activate — core (Proxmark3, Cmd, etc.) # Usage: source activate
# source activate sim — + SimSession, transponder models
# source activate sniff — + SniffSession, trace decoders
# source activate all — everything
# #
# Then: python — REPL with auto-imports # Then: pm3 — REPL with core imports (Proxmark3, Cmd)
# ipython — IPython with auto-imports (if installed) # pm3 sim — + SimSession, all transponder models
# pm3 sniff — + SniffSession, trace decoders
# pm3 all — everything
_PM3PY_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Activate the venv # Activate the venv
source "$(dirname "${BASH_SOURCE[0]}")/.venv/bin/activate" source "${_PM3PY_ROOT}/.venv/bin/activate"
# Set mode and PYTHONSTARTUP # pm3 command — launches REPL with mode
export PM3PY_MODE="${1:-core}" pm3() {
export PYTHONSTARTUP="$(dirname "${BASH_SOURCE[0]}")/.pythonstartup.py" PM3PY_MODE="${1:-core}" python -i "${_PM3PY_ROOT}/.pythonstartup.py"
}
# Update prompt to show mode echo "pm3py env ready. Commands: pm3, pm3 sim, pm3 sniff, pm3 all"
PS1="(pm3py:${PM3PY_MODE}) ${_OLD_VIRTUAL_PS1:-\$ }"
export PS1
echo "pm3py env ready (mode: ${PM3PY_MODE}). Run 'python' for REPL with auto-imports."