-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurl.sh
More file actions
29 lines (29 loc) · 792 Bytes
/
curl.sh
File metadata and controls
29 lines (29 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/env bash
outfile=~/.local/bin/curl
if [ -e $outfile ]; then
echo "请确保 $outfile 文件不存在!!!"
else
mkdir -p ~/.local/bin
echo "#!/bin/env bash
curl_path=$(which curl)" >$outfile
echo 'curl() {
mirror_url="http://hub.fgit.ml"
mirror_raw_url="http://raw.fgit.ml"
url=$@
if [[ $url =~ "://github.com" ]]; then
url=${url/"http://github.com"/$mirror_url}
url=${url/"https://github.com"/$mirror_url}
elif [[ $url =~ "://raw.githubusercontent.com" ]]; then
url=${url/"http://raw.githubusercontent.com"/$mirror_raw_url}
url=${url/"https://raw.githubusercontent.com"/$mirror_raw_url}
fi
$curl_path $url
}
curl $@' >>$outfile
chmod +x $outfile
echo '文件释放完毕
请确认 ~/.local/bin 在PATH中,
否则请执行
export PATH=~/.local/bin:$PATH
'
fi