chore(fish): Update env files

This commit is contained in:
2025-09-23 09:43:20 +02:00
parent bc405a3253
commit b91d3dbe53
3 changed files with 146 additions and 36 deletions

71
.fish/README.md Normal file
View File

@@ -0,0 +1,71 @@
# Exported Fish Environment: ros2-assignments
This directory contains a self-contained Fish shell environment that can be used
without requiring the original Fish configuration.
## Files Structure
```
.fish/
├── activate.fish # Main environment configuration
└── README.md # This file
```
## Usage
### Automatic Activation (Recommended)
The environment will automatically activate when you `cd` into this directory
if your Fish shell is configured with the auto-activation feature that checks
for `.fish/activate.fish`.
### Manual Activation
To manually activate the environment, run from the project root:
```bash
source ./.fish/activate.fish
```
### Deactivation
To deactivate the environment, run:
```bash
env deactivate
```
Or simply `cd` to a different directory if using auto-activation.
## What This Environment Provides
- Custom prompt showing the environment name
- Environment-specific aliases and functions
- Custom environment variables
- Automatic cleanup when deactivated
## Requirements
- Fish shell
- If this is a ROS2 environment: `bass` plugin (`fisher install edc/bass`)
## Sharing
This environment is completely self-contained. You can:
1. Copy this directory to another machine
2. Share it with other Fish shell users
3. Version control it with your project (add .fish/ to your repo)
The environment will work on any system with Fish shell, regardless of whether
they have the original environment management system installed.
## Auto-activation Setup
To enable auto-activation for .fish/activate.fish, add this to your Fish config.fish:
```fish
function check_and_source_activate
if test -f (pwd)/.fish/activate.fish
source (pwd)/.fish/activate.fish
elif test -f (pwd)/activate.fish
source (pwd)/activate.fish
end
end
function cd
builtin cd $argv && check_and_source_activate
end
```

75
.fish/activate.fish Executable file
View File

@@ -0,0 +1,75 @@
# Self-contained environment: ros2-assignments
# Exported on: Tue Sep 23 09:41:57 AM CEST 2025
# Original environment from: /home/wessel/.config/fish/environments/configs/ros2-assignments
# ROS2 development environment (requires distrobox)
# Environment: ros2-assignments
# 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 "ros2-assignments"
# Check if running inside distrobox
if test -f /run/.containerenv; or test -n "$CONTAINER_ID"
# Source ROS2 setup files using bass
if type -q bass
bass source /opt/ros/jazzy/setup.bash
if test -f ./install/setup.bash
bass source ./install/setup.bash
end
else
echo (set_color red)"Error: bass is required for ROS2 environment. Install with: fisher install edc/bass"(set_color normal)
return 1
end
# Set environment variable for the prompt prefix
set -gx ROS2_ACTIVE 1
# 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 ROS2 prefix
function fish_prompt
echo -n (set_color magenta)'(ros2-assignments)'(set_color normal)' '
__env_orig_prompt
end
# ROS2 aliases and functions
alias cb="colcon build"
alias cbs="colcon build --symlink-install"
alias cbt="colcon build --packages-select"
alias ct="colcon test"
alias ctr="colcon test-result"
echo (set_color green)"Activated ROS2 environment: ros2-assignments"(set_color normal)
else
echo (set_color red)"This ROS2 environment should only be run inside a distrobox container"(set_color normal)
return 1
end
# Custom deactivation function
function __env_custom_deactivate
# Remove ROS2-specific variables and aliases
set -e ROS2_ACTIVE
functions -e cb cbs cbt ct ctr 2>/dev/null
echo (set_color blue)"ROS2 environment cleanup completed"(set_color normal)
end

View File

@@ -1,36 +0,0 @@
export env_name="ros2-assignments"
# Check if a previous initialization has occurred
if test -n "$__ACTIVATE_INITIALIZED"
exit 1
end
export __ACTIVATE_INITIALIZED="1"
# Check if running inside distrobox
if test -f /run/.containerenv; or test -n "$CONTAINER_ID"
bass source /opt/ros/jazzy/setup.bash
bass source ./install/setup.bash
# Set environment variable for the prompt prefix
set -gx ROS2_LECTURES_ACTIVE 1
# Save the original prompt function if it exists
if not functions -q __ros2_lectures_orig_prompt
if functions -q fish_prompt
functions -c fish_prompt __ros2_lectures_orig_prompt
else
function __ros2_lectures_orig_prompt
echo -n (whoami)'@'(prompt_hostname)' '(set_color $fish_color_cwd)(prompt_pwd)(set_color normal)'> '
end
end
end
# Define new prompt with ros2-lectures prefix
function fish_prompt
echo -n (set_color green)'('$env_name')'(set_color normal)
__ros2_lectures_orig_prompt
end
else
echo "This script should only be run inside a distrobox container"
exit 1
end