Thursday, November 07, 2013

proxyconf : ターミナルのためのプロキシ切り替えコマンド

proxyconfというターミナルのためのプロキシ切り替えツールをgemでリリースしました。

いつも仕事でMacを使っているとき、Ethernetケーブルでは会社のネットワークに、WiFiでは別のプロバイダのネットワークに繋がっているんですが、会社のネットワークではプロキシサーバーを通さなければ行けません。Macだとブラウザでネットをみるときにはシステム環境設定で設定してあるプロキシを自動的に使ってくれるので問題ないのですが、ターミナルでcurlのようなネット接続するツールを使うにはいちいち環境変数のhttp_proxyを設定しなければいけないのが面倒でした。

そこでターミナルでも現在のネットワークに対応したプロキシを自動的に設定するツールとしてproxyconfを作りました。

インストール

以下の手順でインストールしてください。

$ gem install proxyconf
$ proxyconf-setup

proxyconf-setupコマンドで、~/.proxyconfディレクトリを作り、~/.bash_profileの最後にproxyconf用の設定を読み込むための一行を追加します。この設定は次にターミナルを開いたときから有効になります。インストールしたターミナルですぐに利用する場合は以下のコマンドをターミナルに入力してください。

$ source "$HOME/.proxyconf/proxyconf"

使い方

単純にproxyconfコマンドを実行するだけです。

$ proxyconf
set proxy: yourproxy.com:8080

これで環境変数のhttp_proxy, https_proxy, ftp_proxyに、今使っているネットワークに対してシステム環境設定で設定しているプロキシが設定されます。

アンインストール

以下のコマンドでファイルを削除します。

$ gem uninstall proxyconf
$ rm -rf ~/.proxyconf

次に、以下の行を~/.bash_profileまたは~/.bashrcから削除してください。

[[ -s "$HOME/.proxyconf/proxyconf" ]] && source "$HOME/.proxyconf/proxyconf"

対応OS

現時点ではMacにしか対応していません。今後、Linuxなら対応可能だと思います。Windowsは多分無理かな。一部bashを使っているので。

1 comment:

Unknown said...

Nothing of this could be to assert the keep an eye on will be all sorts of things only an outstanding wristwatch, simply because also the country rare detractors may take into consideration. It consists of really be a bit a lot, and even there was a current cry intended for something a little less ostentatious. Rapidly continuing worldwide recognition for more substantial sporting activities wristwatches within the buyer sector, there does exist any impending and additionally significant improve to the shut horizon. Companies happen to be gradually sizes downwards its selections throughout preparing with the after that large element - which usually usually, shall be scaled-down wristwatches (comparatively discussing they should never ever possibly be tiny and you will definitely not necessarily see sport looks after according to 39mm). These lesser different watches undoubtedly are a awesome commence intended for design, since they may without a doubt reel in a fully new portion of individuals who have been not able to accomplish the more expensive products meant for wearability benefits replica cartier watches, even though moreover arriving maximum circle to your die-hard admirers whose choices usually are getting older past the enormous and blingy and possess ended up weeping released for a specific thing scaled-down plus sustainably wearable.