I am glad that you like it. I was quite surprised, too, that nobody had written such a script yet.
Glad we finally have it and hopefully it’s included as stock in the next release.
The default ros2
command is implemented in Python and python scripts can not change the current working directory, so adding it as a verb there is unfortunately not possible. However, it should be possible to distribute the script as a separate package through the build farm. If there is enough demand, I can look into that.
Maybe worth adding an automatic
cd ..
if the last two dirs are the same?
I am very hesitant to implement such kind of special behavior. It could lead to unexpected results, especially when package and folder have the same name but it is not a meta package.