Files
.config/fish/environments/templates/basic.fish

49 lines
1.5 KiB
Fish

# Basic environment with custom prompt
# 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 green)'({{ENV_NAME}})'(set_color normal)' '
__env_orig_prompt
end
# Add custom environment variables here
# set -gx MY_CUSTOM_VAR "value"
# Add custom paths here
# fish_add_path /path/to/custom/bin
# Custom initialization commands
echo (set_color green)"Activated environment: {{ENV_NAME}}"(set_color normal)
# Optional: Define custom deactivation function
function __env_custom_deactivate
# Add any cleanup commands here
# unset custom variables, restore paths, etc.
echo (set_color blue)"Custom cleanup for {{ENV_NAME}} completed"(set_color normal)
end