Tuesday, 28 July 2009

HOWTO: get stdin from shell in Gedit External Tool

The following code can get the input from Gedit External Tool as you assigned for 'input'.

#!/bin/bash
search=`xargs`
echo $search
The trick is the command of xargs.

Also available Environment Variables in Gedit External Tool are:
=====================
GEDIT_CURRENT_DOCUMENT_URI
GEDIT_CURRENT_DOCUMENT_NAME
GEDIT_CURRENT_DOCUMENT_SCHEME
GEDIT_CURRENT_DOCUMENT_PATH
GEDIT_CURRENT_DOCUMENT_DIR
GEDIT_DOCUMENTS_URI
GEDIT_DOCUMENTS_PATH

An example: compile java file and run it
=========================
javac $GEDIT_CURRENT_DOCUMENT_NAME && java -cp . `echo $GEDIT_CURRENT_DOCUMENT_NAME | sed s/.java//`

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter