# Python development environment # Environment: {{ENV_NAME}} # Check if a previous initialization has occurred if test -n "$__ENV_INITIALIZED" echo (set_color yellow)"Environment already initialized"(set_color normal) return 0 end # Mark as initialized set -gx __ENV_INITIALIZED "1" set -gx CURRENT_ENV "{{ENV_NAME}}" # Save the original prompt function if it exists # Only save if we don't already have a backup or if current prompt is not from an environment if not functions -q __env_orig_prompt if functions -q fish_prompt functions -c fish_prompt __env_orig_prompt else function __env_orig_prompt echo -n (whoami)'@'(prompt_hostname)' '(set_color $fish_color_cwd)(prompt_pwd)(set_color normal)'> ' end end else # If we already have a backup, we're switching environments # No need to create a new backup end # Define new prompt with environment prefix function fish_prompt echo -n (set_color cyan)'({{ENV_NAME}})'(set_color normal)' ' __env_orig_prompt end # Python-specific environment setup set -gx PYTHONPATH (pwd) set -gx VIRTUAL_ENV_DISABLE_PROMPT 1 # Check for Python virtual environment if test -d ./venv set -gx VIRTUAL_ENV (pwd)/venv fish_add_path $VIRTUAL_ENV/bin echo (set_color blue)"Using Python virtual environment: ./venv"(set_color normal) elif test -d ./.venv set -gx VIRTUAL_ENV (pwd)/.venv fish_add_path $VIRTUAL_ENV/bin echo (set_color blue)"Using Python virtual environment: ./.venv"(set_color normal) end # Python aliases alias py="python" alias pip="python -m pip" alias pytest="python -m pytest" alias black="python -m black" alias isort="python -m isort" alias mypy="python -m mypy" echo (set_color green)"Activated Python environment: {{ENV_NAME}}"(set_color normal) # Custom deactivation function function __env_custom_deactivate # Remove Python-specific paths and variables if test -n "$VIRTUAL_ENV" set -e VIRTUAL_ENV end set -e PYTHONPATH set -e VIRTUAL_ENV_DISABLE_PROMPT # Remove Python aliases functions -e py pip pytest black isort mypy 2>/dev/null echo (set_color blue)"Python environment cleanup completed"(set_color normal) end