Skip to content

feat: add support for fish#164

Open
Sunrisepeak wants to merge 4 commits intoament:rollingfrom
Sunrisepeak:feat/add_support_for_fish
Open

feat: add support for fish#164
Sunrisepeak wants to merge 4 commits intoament:rollingfrom
Sunrisepeak:feat/add_support_for_fish

Conversation

@Sunrisepeak
Copy link

No description provided.

Signed-off-by: sunrisepeak <speakshen@163.com>
Signed-off-by: sunrisepeak <speakshen@163.com>
@Sunrisepeak Sunrisepeak changed the title Feat/add support for fish feat: add support for fish Mar 18, 2026
Sunrisepeak added a commit to Sunrisepeak/ros2cli that referenced this pull request Mar 18, 2026
- ament/ament_package#164
- ros2#326

Signed-off-by: sunrisepeak <speakshen@163.com>
Sunrisepeak added a commit to Sunrisepeak/ros2cli that referenced this pull request Mar 18, 2026
- ament/ament_package#164
- ros2#326

Signed-off-by: sunrisepeak <speakshen@163.com>
@Sunrisepeak
Copy link
Author

@Sunrisepeak
Copy link
Author

Test on Ubuntu24.4 (jazzy)

Test (test_fish_support.sh)

#!/bin/bash
set -e

# Test Repo Path
#  - $1: ament_package
#  - $2: ros2cli

if [ -z "$1" ] || [ -z "$2" ]; then
    echo "Usage: $0 <ament_package_repo> <ros2cli_repo>"
    exit 1
fi

AP=$1/ament_package
RC=$2/ros2cli

ROSD=jazzy

echo rosd: $ROSD
echo ament_packge: $AP
echo ros2cli: $RC

echo ---

AP=$1/ament_package
RC=$2/ros2cli

# install prefix-level files
sudo cp $AP/template/prefix_level/setup.fish /opt/ros/$ROSD/setup.fish
sed -e "s|@CMAKE_INSTALL_PREFIX@|/opt/ros/$ROSD|g" \
    -e 's|@ament_package_PYTHON_EXECUTABLE@|/usr/bin/python3|g' \
    $AP/template/prefix_level/local_setup.fish.in | sudo tee /opt/ros/$ROSD/local_setup.fish > /dev/null

sudo cp $AP/template/prefix_level/_local_setup_util.py /opt/ros/$ROSD/_local_setup_util.py

# install ros2cli fish complete
sudo cp $RC/completion/ros2-argcomplete.fish /opt/ros/$ROSD/share/ros2cli/environment/ros2-argcomplete.fish
grep -q 'argcomplete.fish' /opt/ros/$ROSD/share/ros2cli/package.dsv || \
    echo 'source;share/ros2cli/environment/ros2-argcomplete.fish' | sudo tee -a /opt/ros/$ROSD/share/ros2cli/package.dsv > /dev/null

# test
fish -c "
    source /opt/ros/$ROSD/setup.fish
    echo \"ROS_DISTRO = \$ROS_DISTRO\"
    ros2 -h
    functions -q __fish_ros2_complete; and echo \"ros2 completion: OK\"
"

Use in fish shell

bash yourPath/test_fish_support.sh ament_package_LocalRepoPath ros2cli_LocalRepoPath
source /opt/ros/jazzy/setup.fish

Output

rosd: jazzy
ament_packge: .../ament_package/ament_package
ros2cli: .../ros2cli/ros2cli
---
ROS_DISTRO = jazzy
usage: ros2 [-h] [--use-python-default-buffering] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

options:
  -h, --help            show this help message and exit
  --use-python-default-buffering
                        Do not force line buffering in stdout and instead use the python default buffering, which
                        might be affected by PYTHONUNBUFFERED/-u and depends on whatever stdout is interactive or
                        not

Commands:
  action     Various action related sub-commands
  bag        Various rosbag related sub-commands
  component  Various component related sub-commands
  daemon     Various daemon related sub-commands
  doctor     Check ROS setup and other potential issues
  interface  Show information about ROS interfaces
  launch     Run a launch file
  lifecycle  Various lifecycle related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  plugin     Various plugin related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  topic      Various topic related sub-commands
  wtf        Use `wtf` as alias to `doctor`

  Call `ros2 <command> -h` for more detailed usage.
ros2 completion: OK

Signed-off-by: sunrisepeak <speakshen@163.com>
Signed-off-by: sunrisepeak <speakshen@163.com>
@Sunrisepeak
Copy link
Author

pr ready

  • test on ubuntu 24.04
  • Opus4.6/Codex double review + optimze

@asymingt
Copy link
Member

@skyegalaxy tagging you for a review on this one, as I can't seem to assign it to you.

@skyegalaxy
Copy link

@skyegalaxy tagging you for a review on this one, as I can't seem to assign it to you.

@asymingt I don't seem to have write access or merge capabilities to the ament repo

@skyegalaxy
Copy link

skyegalaxy commented Mar 19, 2026

@Sunrisepeak - I ran your branch locally and the generation of package level fish scripts seems to be working well! I'm a bit confused about your testing setup, however. I would expect that by switching my rolling workspace's ament_package to this branch, that I would see a top level install/setup.fish inside my workspace's install folder, but that doesn't seem to be the case and your test script seems to manually add the setup.fish to /opt/ros/$DISTRO. Is adding the top level autogenerated setup.fish out of scope for this PR?

@Sunrisepeak
Copy link
Author

@Sunrisepeak - I ran your branch locally and the generation of package level fish scripts seems to be working well! I'm a bit confused about your testing setup, however. I would expect that by switching my rolling workspace's ament_package to this branch, that I would see a top level install/setup.fish inside my workspace's install folder, but that doesn't seem to be the case and your test script seems to manually add the setup.fish to /opt/ros/$DISTRO. Is adding the top level autogenerated setup.fish out of scope for this PR?

Q1: I would expect that by switching my rolling workspace's ament_package to this branch, that I would see a top level install/setup.fish inside my workspace's install folder, but that doesn't seem to be the case

A1: colcon workspace's setup.fish support by colcon-fish extension, it isnt related with this pr.

Q2: a bit confused - manually add the setup.fish to /opt/ros/$DISTRO

A2: test script just to test top level

for support shell(fish), it isnt same mechanism for workspace level and top level

similar (setup.bash):

  • top-level: this repo + ros2cli (argcomplete)
  • colcon workspace

pls free talk with me, if I have any mistake for setup mechanism

@Sunrisepeak
Copy link
Author

Sunrisepeak commented Mar 19, 2026

If you want test in workspace, you can install colcon-fish

# Install
pip install colcon-fish

# Build your ROS 2 workspace
cd ~/ros2_ws && colcon build

# Source in fish
source install/setup.fish

# Run
ros2 run my_package my_node

Note: colcon-fish test on ubuntu 24.4

@skyegalaxy
Copy link

@Sunrisepeak - I ran your branch locally and the generation of package level fish scripts seems to be working well! I'm a bit confused about your testing setup, however. I would expect that by switching my rolling workspace's ament_package to this branch, that I would see a top level install/setup.fish inside my workspace's install folder, but that doesn't seem to be the case and your test script seems to manually add the setup.fish to /opt/ros/$DISTRO. Is adding the top level autogenerated setup.fish out of scope for this PR?

Q1: I would expect that by switching my rolling workspace's ament_package to this branch, that I would see a top level install/setup.fish inside my workspace's install folder, but that doesn't seem to be the case

A1: colcon workspace's setup.fish support by colcon-fish extension, it isnt related with this pr.

Q2: a bit confused - manually add the setup.fish to /opt/ros/$DISTRO

A2: test script just to test top level

for support shell(fish), it isnt same mechanism for workspace level and top level

similar (setup.bash):

* top-level: this repo + ros2cli (argcomplete)
  
  * ament_package - [files](https://github.com/search?q=repo%3Aament%2Fament_package%20bash&type=code)
  * ros2cli - [files](https://github.com/search?q=repo%3Aros2%2Fros2cli%20bash&type=code)

* colcon workspace
  
  * support by [colcon-bash](https://github.com/colcon/colcon-bash)

pls free talk with me, if I have any mistake for setup mechanism

understood, thank you for clarifying!

Copy link

@skyegalaxy skyegalaxy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the changes in this repo and ros2cli as well as colcon-fish and everything seems to be working! I played around with the cli a bit as well and I'm really happy with the fish tab complete for ROS topics.

@skyegalaxy
Copy link

Pulls: #164, ros2/ros2cli#1211
Gist: https://gist.githubusercontent.com/skyegalaxy/4ab9923e4f12b167a21f2a368ffab9b3/raw/fa2526eb1ea4695d8c8a5bd2d39a0709237d25cb/fish_support.repos
BUILD args: --packages-above-and-dependencies ament_package
TEST args: --packages-above ament_package
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18569/

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@Sunrisepeak
Copy link
Author

@skyegalaxy the ci-unstable seem not related with the pr, Does it need to be rerun?

@skyegalaxy
Copy link

@skyegalaxy the ci-unstable seem not related with the pr, Does it need to be rerun?

agreed, seems like a bunch of unrelated failures (not atypical for rolling).

@asymingt - I can merge the ros2/ros2cli#1211 PR, but my approval here has no effect since I have no write access to the ament repo.

@asymingt asymingt self-requested a review March 20, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants