美文网首页
Mac 使用AppleScript脚本 设置Git代理(对话框篇

Mac 使用AppleScript脚本 设置Git代理(对话框篇

作者: FateOfKing | 来源:发表于2019-07-22 08:52 被阅读0次

国内发现Git Clone特别慢,有什么办法提高吗?
有!
git config --global http.proxy 'socks5://127.0.0.1:端口号'
git config --global https.proxy 'socks5://127.0.0.1:端口号'
两句话搞定。

但是公司项目又是部署在公司内网的,不能使用代理,所以每次都要切换,很麻烦。于是做了小脚本。
(AppleScript使用方法看我上一篇文章

(后来发现可以用git config --global http.https://github.com.proxy 'socks5://127.0.0.1:端口号' 单独对github设置,这工具就没用了。本文就当记录dialog怎么用的吧)。

tell application "代理工具名字
    run
end tell

display dialog "请选择是否打开Git代理" buttons {"打开", "关闭"} default button "打开" with title "提示"
set returnRecord to the result --获取返回的record类型的值
if returnRecord is {button returned:"打开"} then
    tell application "Terminal"
        do shell script "git config --global http.proxy 'socks5://127.0.0.1:端口号' && git config --global https.proxy 'socks5://127.0.0.1:端口号'"
    end tell
else
    tell application "Terminal"
        do shell script "git config --global --unset http.proxy && git config --global --unset https.proxy"
        
    end tell
end if

打开代理工具
弹出对话框,是否打开Git代理,根据选择的按钮,执行不同的方法

相关文章

网友评论

      本文标题:Mac 使用AppleScript脚本 设置Git代理(对话框篇

      本文链接:https://www.haomeiwen.com/subject/nmzblctx.html