Created
December 29, 2010 23:44
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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