Skip to content

Instantly share code, notes, and snippets.

@bitinn
Last active November 22, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitinn/f6b3df6d7ac52acd94ea646c675439de to your computer and use it in GitHub Desktop.
Save bitinn/f6b3df6d7ac52acd94ea646c675439de to your computer and use it in GitHub Desktop.
Using kneesocks as bash command
alias npm-proxy='launchctl start com.dev.proxy'
alias npm-direct='launchctl stop com.dev.proxy; npm config delete proxy; npm config delete https-proxy'
  • npm install kneesocks -g
  • Make sure you edit the port number in com.dev.proxy.plist
  • Put com.dev.proxy.plist at ~/Library/LaunchAgents
  • Run sudo launchctl unload -w ~/Library/LaunchAgents/com.dev.proxy.plist to enable this service
  • Edit ~/.bash_profile and add those 2 lines
  • Use npm-proxy and npm-direct to toggle proxy for npm
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dev.proxy</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>npm config set proxy http://127.0.0.1:10002; npm config set https-proxy http://127.0.0.1:10002; kneesocks 10002 10001</string>
</array>
</dict>
</plist>
@bitinn
Copy link
Author

bitinn commented Nov 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment