proxychains ng 的 ng 是 new generation 的意思,其实就是 proxychains4。
首先本地开启 socks5 代理(端口有了),然后继续:
1
| $ apt install proxychains4
|
1
| $ vim /etc/proxychains.conf
|
网上有些博文写的 proxychains4 用 /etc/proxychains4.conf
。
当然是可以的,但就直接 /etc/proxychains.conf
也会生效。
甚至两个文件都存在的时候 proxychains.conf
的优先级比 proxychains4.conf
高。
中间都不用管,拉到最后:
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
#socks4 127.0.0.1 9050
socks5 [子网IP] [socket端口]
注意:如果是 WSL2 的话,IP 应该是
1
| $ cat /etc/resolv.conf | grep nameserver | awk '{print $2}'
|
1
2
| $ curl www.httpbin.org/ip
$ proxychains4 curl www.httpbin.org/ip
|
接口返回的两个本机 IP 不一致,说明开启代理成功了。
大多数 Linux 系统默认终端是 /bin/bash
:
1
2
3
| $ echo $0 # 当前shell 也就是shell脚本开头#!/bin/bash声明的东西
$ echo $SHELL # 默认shell
$ cat /etc/shells # 所有shell
|
1
2
3
4
| $ apt-get install zsh -y
$ zsh --version
zsh 5.8 (x86_64-ubuntu-linux-gnu)
|
1
2
3
4
| $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 或者
$ sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 取决你用哪个客户端 curl还是wget
|
此处大概率会出现网络问题,我以前 WSL 1 问题不大,升成 WSL 2 全局也救不了。
这时就该前面装好的 proxychains4 出场了,注意 proxychains 的用法。
它不是新建一个虚拟网络环境,然后在虚拟环境里运行所有命令,哪有这么炫酷。
它能代理的只有紧接在后面的命令,比如上面安装 zsh 那条:
1
2
3
4
5
| $ proxychains4 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 这是错误用法 代理sh是想干嘛
$ sh -c "$(proxychains4 wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 这是正确姿势 用proxychains4代理wget
|
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
老规矩,网络问题 proxychains4 解决。
1
| $ git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
|
1
| $ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
|
其实默认的 robbyrussell 就很棒,简洁大方。
不过我最喜欢 agnoster,就一个字,精致。
用不同前景色背景色配合做出来的箭头形分隔符真的很有创意,设计感拉满。
另外推荐 pure,清爽到性冷淡。
如果想用 更多主题 要 ls ~/.oh-my-zsh/themes | grep [主题名字]
看看本地有没有。
有的话可以直接修改配置启用。没有的话就要另行下载(git clone
)了。
1
2
3
4
5
| plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| alias rzsh="source ~/.zshrc"
# cnpm
alias cnpm="npm --registry=https://registry.npm.taobao.org \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npm.taobao.org/dist \
--userconfig=$HOME/.cnpmrc"
# 怎么舒服怎么来 比如 WSL 快速到达外面路径的快捷方式
alias gowork="cd /mnt/d/Workspace/Git"
# 再比如之前装好的 proxychains4
alias px="proxychains4"
# 如果装了 supervisorctl
alias sv="supervisorctl"
alias svcfg="vim /etc/supervisor/supervisord.conf"
alias svr="supervisorctl update all && supervisorctl reload"
# 对了 thefuck 也要特别为 zsh 配置
eval $(thefuck --alias fuck)
# 等等
|
不过不推荐在这里配置 git 别名,git alias 还是老实写在 ~/.gitconfig
里吧。