Created
September 22, 2016 17:01
-
-
Save jhjin/d4dc44a3c20be477167f8af2fe15e285 to your computer and use it in GitHub Desktop.
a convenient shell script to vim a file under ROS package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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