Skip to content

Instantly share code, notes, and snippets.

@mapix
Last active December 17, 2015 18:39
Show Gist options
  • Select an option

  • Save mapix/5655003 to your computer and use it in GitHub Desktop.

Select an option

Save mapix/5655003 to your computer and use it in GitHub Desktop.
svn&git repo autocomplete file in vim
function is_git_repository {
git branch > /dev/null 2>&1
}
function is_svn_repository {
test -d .svn
}
if is_git_repository ; then
git ls-files | dmenu -i -l 20 -p $1
elif is_svn_repository ; then
find . -iwholename "*$1*" -type f -not \( -name '*pyc' -o -name '*py~' -o -name '*.swp' -o -name '*un~' \) -not -iwholename '*.svn*' -not -iwholename '*.git*'| dmenu -i -l 20 -p $1
fi
@mapix
Copy link
Copy Markdown
Author

mapix commented May 27, 2013

" Strip the newline from the end of a string
function! Chomp(str)
  return substitute(a:str, '\n$', '', '')
endfunction

" Find a file and pass it to cmd
function! DmenuOpen(cmd)
  let fname = Chomp(system("~/bin/autocomplete.sh " . a:cmd))
  if empty(fname)
    return
  endif
  execute a:cmd . " " . fname
endfunction

map <c-t> :call DmenuOpen("tabe")<cr>
map <c-f> :call DmenuOpen("e")<cr>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment