views:

32

answers:

2

I consistently run the ruby sudo gem install mygem command with these two options on my production system:

sudo gem install mygem --no-ri --no-rdoc

I do that to save a little on space and on how long it takes to setup the documentation. Is there a way (other than hardcoding them into the bin/gem file) to say 'always run this command with these options'?

I figure someone might have a neat little one liner to insert this into the appropriate file with unix/linux somehow...

+2  A: 

If I understand you correctly, you can add this to your $HOME/.gemrc file:

gem: --no-ri --no-rdoc

and then run gem as:

sudo gem install mygem
Alok
thank you, good to know about this
viatropos
+1  A: 

In your home directory there should be a .bashrc file or something similar that gets sourced at each bash session.

Put this in there at the end.

function gemi {
    sudo gem install $1 --no-ri --no-rdoc
}

This is simple but you'd be calling the function "gemi" rather than the sudo gem command. You'd call it like

gemi mygem

Intercepting those commands and replacing them with a wrapper function is a little complicated as far as passing arguments and such.

I am unfamiliar with ruby and the gem command but you may want to look at the man page

man gem

And see if there are environment variables for doing such things like how the Linux/Unix command grep uses GREP_OPTIONS environment variable.

eric.frederich