28 Jun 2012

Compile and Run a C file from wihin gedit

I use gedit to write simple C programs. The External Tools plugin is really helpful for compiling and running them. Here is a simple example to invoke gcc and run the compiled file:

#!/bin/sh

EHOME=`echo $HOME | sed "s/#/\#/"`
DIR=$GEDIT_CURRENT_DOCUMENT_DIR
BASENAME=`echo "$GEDIT_CURRENT_DOCUMENT_NAME" | sed -e 's/\.c$//'`

cd "$GEDIT_CURRENT_DOCUMENT_DIR"
date
gcc -o "$BASENAME" "$GEDIT_CURRENT_DOCUMENT_NAME"