Created
July 15, 2013 23:36
-
-
Save goatslacker/6004481 to your computer and use it in GitHub Desktop.
time tracking local
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
" Lets me know how much time I've spent editing a file | |
" Keyboard shortcut -> \dt | |
augroup TimeSpentEditing | |
au! | |
au BufWinEnter * if !exists('b:tstart')|let b:tstart=reltime()|en | |
augroup END | |
function! TimeSpentEditing() | |
let secs = str2nr(reltimestr(reltime(b:tstart))) | |
let hours = secs / 3600 | |
let minutes = (secs - hours * 3600) / 60 | |
let seconds = secs - hours * 3600 - minutes * 60 | |
return printf("%d:%02d:%02d", hours, minutes, seconds) | |
endfunction | |
function! s:logTimespent() | |
let curFile = expand("%:p") | |
let time = TimeSpentEditing() | |
let path = expand("$HOME/.vimtime") | |
execute ":silent !echo " . curFile . " : " . time . " >> " . path | |
endfunction | |
autocmd BufWritePost * call s:logTimespent() | |
com! TimeSpentEditing echo TimeSpentEditing() | |
map <silent> <leader>dt :TimeSpentEditing<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment