linux - 从 txt 向 Git bash 添加函数

标签 linux git bash shell github

我正在使用 GIT bash。 我有这个文件“proxy_functions.txt”:

 function proxy(){
     echo -n "username:"
     read -e username
     echo -n "password:"
     read -es password
     export http_proxy="http://$username:$password@proxy:8080/"
     export https_proxy=$http_proxy
     export ftp_proxy=$http_proxy
     export rsync_proxy=$http_proxy
     export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
     echo -e "\nProxy environment variable set."
 }

 function proxyoff(){
     unset HTTP_PROXY
     unset http_proxy
     unset HTTPS_PROXY
     unset https_proxy
     unset FTP_PROXY
     unset ftp_proxy
     unset RSYNC_PROXY
     unset rsync_proxy
     echo -e "\nProxy environment variable removed."
 }

加载到我的 GIT bash 中,以便当我在 shell 中写入“代理”,然后我的用户并传递代理以使 GIT bash 准备好将内容推送到我在 GIT 中心的在线存储库时...

它曾经工作得很好,但现在我想我搞砸了,因为当我在 GIT bash 中写“代理”时,它说

bash: proxy: command not found

如何从写入命令的 txt 文件“proxy_functions.txt”中将命令重新插入到 GIT bash 中?

最佳答案

您需要在 bash.bashrc 文件中获取 proxy_functions.txt 脚本。因此,例如,如果 proxy_functions.txt 位于 C:\Users\Arcones\proxy_functions.txt,那么您将需要在 bash.bashrc 中添加一行 文件说:

source C:\Users\Arcones\proxy_functions.txt

关于linux - 从 txt 向 Git bash 添加函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36696204/

相关文章:

linux - 递归遍历目录并在 CLI 上提取文件一个目录

c - 时钟时间和墙上时间有什么区别?

Git参数管道脚本

git - 不知何故,我的 git develop 分支被 merge 到了我的 master 分支中

bash - 如何制作一个 bash 脚本,对目录中的每个文件分别使用 cdhit?

linux - 想要从具有页眉页脚的文件中获取分隔数据,以便进行数据处理以进行性能分析

linux - Until 循环不终止或保持增量变量的值

c - 如何使用 libxcb-xinput 注册事件

linux - 强制内核中的进程休眠 60 秒

git - 为什么在 git 别名中,$0 可以是调用的程序或第一个位置参数?