ruby - Alias to sudo gem --proxy <PROXY> or bash function? -
i have script run when behind proxy called proxy.sh auto-sets various proxy settings such as:
http_proxy=<proxy>https_proxy=<proxy>
once run script love if auto-intercept ruby gem command , add proxy information well:  
sudo gem install .....  => sudo gem install --http-proxy=<proxy> ....
at first wanted write alias understand need make function? correct?
how handle this?
if run proxy.sh typing:  sudo gem install test automatically run sudo gem install --http-proxy=<proxy> test
you make alias. in ~/.bash_aliases :
alias sudo="sudo " alias gemproxy="gem install --http-proxy=<proxy>"   the sudo alias (with space) important if want use alias gemproxy sudo.
edit : intercept gem install, can add in .bash_aliases :
gem() {     if [[ $@ == install* ]];         arg=${@#"install "}         command gem install --http-proxy=proxy $arg     fi }   but this, export proxy if you're not behind it. can add verification see if environment variable http_proxy set.
Comments
Post a Comment