Ruby Script Runner for Ubuntu Gedit

657 Views Asked by At

I have this Java script runner installed in my gedit external tools:

#!/bin/sh
cd $GEDIT_CURRENT_DOCUMENT_DIR
if javac $GEDIT_CURRENT_DOCUMENT_NAME;
then
java ${GEDIT_CURRENT_DOCUMENT_NAME%\.java}
else
echo "Failed to compile"
fi

I tried modifying to it to something like this

#!/bin/sh
cd $GEDIT_CURRENT_DOCUMENT_DIR
ruby ${GEDIT_CURRENT_DOCUMENT_NAME%\.rb}

but it doesn't work. I may have missed something, I don't know what because I don't do bash scripting. Hehe

2

There are 2 best solutions below

0
On BEST ANSWER

GEDIT_CURRENT_DOCUMENT_NAME includes the file extension.

So just do:

#!/bin/sh
cd $GEDIT_CURRENT_DOCUMENT_DIR
ruby $GEDIT_CURRENT_DOCUMENT_NAME
4
On

Make sure the script is executable

chmod +x my_script.sh