プロキシという名の『吐き気を催すほどの邪悪』.
一括設定バッチファイルを組んで,少しでも作業を効率化してやろうと,模索した.
注意事項
- hgについては予め,proxy有りを想定した
mercurial.ini
をmercurial.ini.proxy.txt
として,proxy無しを想定したmercurial.ini
をmercurial.ini.noproxy.txt
として,ユーザーフォルダに作成しておく. - netsh winhttpに関してはWindows 10の「設定アプリ」(8.1以前の場合は「インターネット オプション」)を流用するので,バッチファイル実行前にあらかじめ設定しておく.
- 管理者権限で実行すること(proxy_pip.batを除く).
プロキシ一括設定
proxy_set.bat
echo off
rem プロキシ設定
set USER_PROXY_ID="username"
set USER_PROXY_PASS="password"
set USER_PROXY="proxy.example.com:8080"
rem netsh winhttp(ここだけGUI設定からのインポート)
netsh winhttp import proxy source=ie
rem git
git config --global http.proxy http://%USER_PROXY_ID%:%USER_PROXY_PASS%@%USER_PROXY%
git config --global https.proxy http://%USER_PROXY_ID%:%USER_PROXY_PASS%@%USER_PROXY%
rem hg
copy /Y %USERPROFILE%\mercurial.ini.proxy.txt %USERPROFILE%\mercurial.ini
プロキシ一括解除
proxy_unset.bat
echo off
rem netsh winhttp
netsh winhttp reset proxy
rem git
git config --global --unset http.proxy
git config --global --unset https.proxy
rem hg
copy /Y %USERPROFILE%\mercurial.ini.noproxy.txt %USERPROFILE%\mercurial.ini
pipについて
- ユーザーフォルダに,以下のバッチファイルを作っておき,コマンドプロンプトから実行する.以下の設定はコマンドプロンプトの今実行中のプロセスにのみ適用される.(なので,解除したければ一回コマンドプロンプトを閉じればOK)
- 実行するときのコマンドは
%USERPROFILE%\proxy_pip
proxy_pip.bat
set HTTP_PROXY=http://username:password@proxy.example.com:8080
set HTTPS_PROXY=http://username:password@proxy.example.com:8080