Skip to content

Instantly share code, notes, and snippets.

@bps
Created September 30, 2009 18:42
Show Gist options
  • Save bps/198337 to your computer and use it in GitHub Desktop.
Save bps/198337 to your computer and use it in GitHub Desktop.
A vim function that will load a per-git-project vimrc.
vim ()
{
local vimrc="vimrc" # Name you want to use for your vimrc in .git/
local v="$(which vim)" # Or whatever vim you want
local g="$(__gitdir)" # This comes from the git bash completion script
if [ -z "${g-}" ]; then
"${v}" "$@"
else
local vrc="${g}/${vimrc}"
if [ -r "${vrc}" ]; then
"${v}" -S "${vrc}" "$@"
else
"${v}" "$@"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment