Permalink
Browse files

And now with 100% more git ssh agent

  • Loading branch information...
1 parent 1f35f6b commit c6fcfcf1cd94baecfb426765ecf32a01e0b04cb4 @VanTanev committed Jun 19, 2011
Showing with 48 additions and 28 deletions.
  1. +46 −0 .bash-ssh-agent.sh
  2. +1 −0 .bashrc
  3. +1 −0 .gitignore
  4. +0 −28 .vimrc
View
@@ -0,0 +1,46 @@
+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 ssh-agent > /dev/null
+ if [ $? -eq 0 ]; then
+ test_identities
+ else
+ start_agent
+ fi
+fi
+
View
@@ -1,4 +1,5 @@
source .git-flow-completion.sh
+source .bash-ssh-agent.sh
# some more ls aliases
alias ls='ls --color=auto'
View
@@ -5,3 +5,4 @@
!.gitconfig
!.gitignore
!.git-flow-completion.sh
+!.bash-ssh-agent.sh
View
28 .vimrc
@@ -29,31 +29,3 @@ if has("autocmd")
endif " has("autocmd")
-
- set nocompatible " be iMproved
- filetype off " required!
-
- set rtp+=~/.vim/bundle/vundle/
- call vundle#rc()
-
- " let Vundle manage Vundle
- " required!
- Bundle 'gmarik/vundle'
-
- " My Bundles here:
- "
- " original repos on github
- Bundle 'tpope/vim-fugitive'
- Bundle 'lokaltog/vim-easymotion'
- Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
- Bundle 'scrooloose/nerdtree'
- Bundle 'altercation/vim-colors-solarized'
- " vim-scripts repos
- Bundle 'L9'
- Bundle 'FuzzyFinder'
- " non github repos
- Bundle 'git://git.wincent.com/command-t.git'
- " ...
-
- filetype plugin indent on " required!
-

0 comments on commit c6fcfcf

Please sign in to comment.