How to easily forward/redirect all network traffics through local socks port 1080?
Since nobody posts a shell script (or easy way) to solve my question, I posted my current workaround solution:


Install virtualbox
Install openwrt as the guest OS to virtualbox
Configure the openwrt to become a router which has the lan IP of 192.168.56.2. The lan interface is a Host-only adapter. The wan interface is Bridged adapter. 
Configure the openwrt router to do the transparent proxy job that I want.
Change both gateway and DNS to 192.168.56.2 in the host. 


to change the gateway: sudo route change default 192.168.56.2
to change the DNS: must use the UI way. System Preferences --> Network --> Adavanced --> DNS



That's all. So far so good.