(Windows 7中)我的.bashrc文件上的Git Bash的启动不执行 [英] My .bashrc file not executed on Git Bash startup (Windows 7)
问题描述
这是我做过什么:
cd ~
touch .bashrc
notepad .bashrc
和我的.bashrc的内容(在网络上找到的地方):
and the content of my .bashrc is (found on the web somewhere):
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
ssh-add
}
# test for identities
function test_identities {
# test whether standard identities have been added to the agent already
ssh-add -l | grep "The agent has no identities" > /dev/null
if [ $? -eq 0 ]; then
ssh-add
# $SSH_AUTH_SOCK broken so we start a new proper agent
if [ $? -eq 2 ];then
start_agent
fi
fi
}
# check for running ssh-agent with proper $SSH_AGENT_PID
if [ -n "$SSH_AGENT_PID" ]; then
ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
if [ $? -eq 0 ]; then
test_identities
fi
# if $SSH_AGENT_PID is not properly set, we might be able to load one from
# $SSH_ENV
else
if [ -f "$SSH_ENV" ]; then
. "$SSH_ENV" > /dev/null
fi
ps -ef | grep "$SSH_AGENT_PID" | grep -v grep | grep ssh-agent > /dev/null
if [ $? -eq 0 ]; then
test_identities
else
start_agent
fi
fi
不知何故不执行该脚本的。我没有看到任何应呼应琴弦。我熟悉在Linux和Mac OS X的Unix命令行,但我不知道它是如何工作在Windows下。有什么建议吗?
Somehow that script is not executed at all. I don't see any of the strings that should be echoed. I am familiar with Unix commandline in Linux and Mac OS X, but I have no idea how it works under Windows. Any suggestions please?
编辑:好的,我的失误......这个脚本执行,但我不完全理解它做什么。我希望,至被要求p $ pvent的密码每次我推到远程回购的时间。就目前我还在问每一次。
Okay, my mistake... this script is executed, but I don't fully understand what it does. I was hoping to prevent being asked for passphrase every time I push to remote repo. As it stands now I'm still asked every time.
推荐答案
宾果!一些明显错误的使用ssh-agent时在.bashrc中运行的方式。我复制从这里的一个,它的工作原理一种享受!现在,我只有在混帐的bash启动时输入一次密码我,和任何后续推不再需要它了。
Bingo! Something was obviously wrong with the way the ssh-agent is run in that .bashrc. I copied the one from here and it works a treat! Now I only have to enter my passphrase once when git bash starts up, and any subsequent push no longer need it.
下面是脚本的具体内容现在:
Here's the actual content of the script now:
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
echo succeeded
chmod 600 ${SSH_ENV}
. ${SSH_ENV} > /dev/null
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. ${SSH_ENV} > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
这篇关于(Windows 7中)我的.bashrc文件上的Git Bash的启动不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!