Skip to content

Instantly share code, notes, and snippets.

@christoomey
Created December 29, 2010 23:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoomey/759231 to your computer and use it in GitHub Desktop.
Save christoomey/759231 to your computer and use it in GitHub Desktop.
Git aware command T functions. Use git repo top level as Command T context, else top level
function! Command_T_Local() "Go to the root of the git repo, then CommandT
"Ask git for the root of the git repo (as a relative '../../' path)
let git_top = system('git rev-parse --show-cdup')
let git_fail = 'fatal: Not a git repository'
if strpart(git_top, 0, strlen(git_fail)) == git_fail
" Above line says we are not in git repo. Ugly. Better version?
call Command_T_Work()
else
" Move working dir to root of repo, then CommandT
execute ":cd ./" . git_top
CommandT
endif
endfunction
function! Command_T_Work() "Go from the ~/work repo
cd ~/work
CommandT
endfunction
nnoremap <LEADER>fow :call Command_T_Work()<cr>
nnoremap <LEADER>fop :call Command_T_Local()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment