# Node.js 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 yellow)'({{ENV_NAME}})'(set_color normal)' ' __env_orig_prompt end # Node.js specific setup if test -f ./package.json echo (set_color blue)"Found package.json - Node.js project detected"(set_color normal) end # Add node_modules/.bin to PATH if it exists if test -d ./node_modules/.bin fish_add_path ./node_modules/.bin echo (set_color blue)"Added ./node_modules/.bin to PATH"(set_color normal) end # Node.js aliases alias nr="npm run" alias ni="npm install" alias nid="npm install --save-dev" alias nig="npm install --global" alias nu="npm uninstall" alias nug="npm uninstall --global" alias nt="npm test" alias ns="npm start" alias nb="npm run build" echo (set_color green)"Activated Node.js environment: {{ENV_NAME}}"(set_color normal) # Custom deactivation function function __env_custom_deactivate # Remove Node.js aliases functions -e nr ni nid nig nu nug nt ns nb 2>/dev/null echo (set_color blue)"Node.js environment cleanup completed"(set_color normal) end