Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add imports to groovysh on startup?

I'm working on a project where I'd like users to experiment with Java classes on Groovysh. I'd like to make it convenient for them and want to import certain packages by default, when groovysh starts up so that users would not have to re-type the same imports every time they start the shell. Does anyone know how to accomplish this?

Thanks in advance, igor

like image 857
ipolevoy Avatar asked Jun 15 '10 00:06

ipolevoy


2 Answers

You can add the imports to $HOME/.groovy/groovysh.rc

like image 113
Matthew Flaschen Avatar answered Nov 15 '22 07:11

Matthew Flaschen


From http://groovy.codehaus.org/Groovy+Shell:

This script, if it exists, is loaded when the shell starts up:

$HOME/.groovy/groovysh.profile

This script, if it exists, is loaded when the shell enters interactive mode:

$HOME/.groovy/groovysh.rc

Edit-line history is stored in this file:

$HOME/.groovy/groovysh.history
like image 41
gavenkoa Avatar answered Nov 15 '22 08:11

gavenkoa