linux terminal clash

布置环境

mkdir clash
cd clash

下载 clash 包

先在 Windows 中进入网址下载 clash-linux-amd64-v1.18.0.gz,然后传入 Linux 中(因为 Linux 可能连不上该网址)。
gzip -d clash-linux-amd64-v1.18.0.gz
mv clash-linux-amd64-v1.18.0 clash
chmod 755 clash

传入配置

生成默认配置

./clash -d .
输入该命令后会出现几行东西,然后会卡住。实际上 Clash 已经在运行了,可以新开一个终端查看是否生成了配置文件。

导入机场配置

拉取机场配置,注意文件名称必须为 config.yaml

wget xxxx
./clash -d .

日常使用

添加别名到 ~/.bashrc 中:

~/.bashrc
# Clash aliases
alias clash_start="screen -S clash /home/myz/clash/clash -d /home/myz/clash/"
alias clash_stop="pkill clash"
alias proxy_on="export https_proxy=127.0.0.1:7890 && export http_proxy=127.0.0.1:7890"
alias proxy_off="unset http_proxy https_proxy"

使用步骤

  1. 1 重新载入配置
    source ~/.bashrc
  2. 2 启动 Clash
    clash_start

    会进入 screen,按 Ctrl + a + d 退出后台

  3. 3 开启代理
    proxy_on
  4. 4 测试连接
    curl https://www.youtube.com/

GitHub 加速

先用 git config --list 查看是否已有配置:

git config --list

如果有配置,可以先删除:

git config --global --unset user.name
git config --global --edit

然后配置代理:

git config --global http.proxy 'http://127.0.0.1:7890'
git config --global https.proxy 'https://127.0.0.1:7890'

感谢阅读