Though colcon isn't designed for ROS1 system, I'd like to jump to package location like roscd
and build package like catkin tools
.
Here is a temporary solution, please copy and paste that to .bashrc
COLCON_ROOT=/home/user/colcon_ws
function colconcd () {
local prefix path str arr
prefix=${1%/}
if [ $prefix ]; then
path=`roscd ${prefix} && pwd`
str=`cat $path/cmake/${prefix}Config.cmake | grep src | xargs`
arr=(${str// / })
cd ${arr[1]%")"}
else
cd $COLCON_ROOT
fi
}
function colcon-build () {
local path
path=`pwd`
if [ $1 ]; then
cd $COLCON_ROOT
colcon build --packages-select ${1%/}
cd $path
else
cd $COLCON_ROOT
colcon $COLCON_ROOT/build
cd $path
fi
}
complete -F "_roscomplete_sub_dir" -o "nospace" "colconcd"
complete -F "_roscomplete_sub_dir" -o "nospace" "colcon-build"
colconcd
command works like roscd
and you can build specific package anywhere in work space with colcon-build
.