Skip to content

Instantly share code, notes, and snippets.

@jhjin
Created September 22, 2016 17:01
Show Gist options
  • Save jhjin/d4dc44a3c20be477167f8af2fe15e285 to your computer and use it in GitHub Desktop.
Save jhjin/d4dc44a3c20be477167f8af2fe15e285 to your computer and use it in GitHub Desktop.
a convenient shell script to vim a file under ROS package
function rosvim {
ROSVIM_FNAME=$1
if [ ! -f $ROSVIM_FNAME ]; then
ROSVIM_PKGS="package1 package2 package3"
for PKG_NAME in $ROSVIM_PKGS; do
ROSVIM_PKG_PATH=$(rospack find $PKG_NAME 2> /dev/null)
if [ $? -eq 0 ]; then
ROSVIM_FNAME_FULL=$(find -L $ROSVIM_PKG_PATH -name "$ROSVIM_FNAME" | head -n1)
if [ ! -z $ROSVIM_FNAME_FULL ]; then
ROSVIM_FNAME=$ROSVIM_FNAME_FULL
break
fi
fi
done
fi
if [ "$ROSVIM_FNAME" == "$1" ]; then
echo "[ROSVIM] open a new file (./$ROSVIM_FNAME) since it does not exist in ROS workspace."
else
echo "[ROSVIM] open the existing file ($ROSVIM_FNAME)"
fi
vim $ROSVIM_FNAME
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment