dotfiles/.config/zsh/ros.zsh

44 lines
1.0 KiB
Bash

#
# ROS stuff for ZSH
#
function ros-version {
if [[ $1 == '' ]]; then
if [[ $ROS_DISTRO == '' ]]; then
echo 'Error: no ROS distribution active' >&2
return 1
else
echo ROS Distribution: $ROS_DISTRO
echo ROS Version: $ROS_VERSION
fi
else
source /opt/ros/$1/setup.zsh
fi
}
function ros-load-workspace {
if [[ $1 == '' ]]; then
echo 'Error: No workspace directory given' >&2
return 1
elif [[ ! -d $1 ]]; then
echo 'Error: workspace directory does not exist' >&2
return 2
elif [[ $ROS_VERSION != '2' ]] && ([[ ! -d $1/devel ]] || [[ ! -f $1/devel/setup.zsh ]]); then
echo 'Error: directory is not a ROS workspace' >&2
return 3
elif [[ $ROS_VERSION == '2' ]] && ([[ ! -d $1/install ]] || [[ ! -f $1/install/local_setup.zsh ]]); then
echo 'Error: directory is not a ROS workspace' >&2
return 3
else
if [[ $ROS_VERSION == '2' ]]; then
source $1/install/local_setup.zsh
else
source $1/devel/setup.zsh
fi
ROS_WORKSPACES=$ROS_WORKSPACES:$(readlink -f $1)
fi
}
export ROS_DOMAIN_ID=37