tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
19.82k stars 1k forks source link

Enable keychain when invoking :Git push #55

Closed pielgrzym closed 13 years ago

pielgrzym commented 13 years ago

Hi,

I'm not sure if this is even possible, but who knows :) When I commit some changes and try to push them into a remote I recieve an error telling me the host rejected me due to key verification failiure. Obviously the keychain is not present in vimconsole (or whatever starts the git command). Would it be possible to fix that?

tpope commented 13 years ago

This is OS X I take it? Are you running MacVim or console Vim?

pielgrzym commented 13 years ago

Hi,

nope - this is Arch Linux running no DE, just Xmonad + some basic stuff like tmux, zsh etc. I start gvim with dmenu :)

tpope commented 13 years ago

Okay, so I take it you are referring to ssh-agent then. If you echo $SSH_AGENT_PID in a terminal, do you see a pid? What about if you :echo $SSH_AGENT_PID in gvim?

pielgrzym commented 13 years ago

In console there is a PID when I issue in vim (in console) :!echo $SSH_AGENT_PID there is the pid, when I run gvim with dmenu echo in gvim shows nothing, when I fork gvim from terminal - I've got a pid. No need for tweaking vim-fugitive then :) I'll just run gvim from inside urxvt and issue solved :) thanks for pointing this var :)

tpope commented 13 years ago

Great! Note that if you really care to troubleshoot it, it is quite possible to make it work both ways (I can invoke gvim from fvwm's menus in Debian and $SSH_AGENT_PID is set), but how to do it varies from distro to distro, and I can't speak for Arch Linux.

mathstuf commented 13 years ago

Getting the ssh-agent info .xinitrc is the easiest solution. I also put it in every zsh instance as well.

pielgrzym commented 13 years ago

@mathstuf - how do you handle key password prompt in xinitrc?

pielgrzym commented 13 years ago

@tpope, I'll investigate the problem. Most likely it's due to my minimalistic configuration, which uses keychain only in zshrc :)

mathstuf commented 13 years ago

I don't handle passwords at X start. I start the daemon (using keychain, link below) there (or "attach" if it's already running) and any ssh-add calls from there get shared to all other shells and the X session. I have so many ssh keys (they're also symlinked to an automounted directory if my USB key is found, so they may not be accessible anyways) that asking for passwords would be really cumbersome.

http://freshmeat.net/projects/keychain