diff options
| author | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
|---|---|---|
| committer | Franck Cuny <franckcuny@gmail.com> | 2016-08-04 11:45:44 -0700 |
| commit | 585b48b6a605cb71ef99dd767880e1b7ee5bf24e (patch) | |
| tree | c65377350d12bd1e62e0bdd58458c1044541c27b /posts/2008-12-05-vim-and-git.org | |
| parent | Use Bullet list for the index. (diff) | |
| parent | Mass convert all posts from markdown to org. (diff) | |
| download | lumberjaph-585b48b6a605cb71ef99dd767880e1b7ee5bf24e.tar.gz | |
Merge branch 'convert-to-org'
Diffstat (limited to '')
| -rw-r--r-- | posts/2008-12-05-vim-and-git.org | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/posts/2008-12-05-vim-and-git.org b/posts/2008-12-05-vim-and-git.org new file mode 100644 index 0000000..3367bce --- /dev/null +++ b/posts/2008-12-05-vim-and-git.org @@ -0,0 +1,42 @@ +idea from +[[http://use.perl.org/use.perl.org/_Ovid/journal/37966.html][Ovid's +journal]] (ovid is full of really good ideas for vim): + +to get a quick git diff in my vim session, put this in your .vimrc + +#+BEGIN_EXAMPLE + map ,gh :call SourceDiff() " gh for git history + + function! SourceDiff() + let filename = bufname("%") + let command = 'git log -5 --pretty=format:"%h - (%ar) %an - %s" "'.filename.'"' + let result = split( system(command), "\n" ) + + if empty(result) + echomsg("No past revisions for " . filename) + return + endif + + " get the list of files + let revision = PickFromList('revision', result) + + if strlen(revision) + let items = split(revision, " ") + execute '!git diff ' . items[0] . ' -- "' . filename .'" | less' + endif + endfunction +#+END_EXAMPLE + +the output looks like this: + +#+BEGIN_EXAMPLE + Choose a revision: + 1: ea0bb4d - (3 days ago) franck cuny - fix new_freq + 2: a896ac7 - (5 weeks ago) franck cuny - fix typo + 3: c9bc5fd - (5 weeks ago) franck cuny - update test + 4: e9de4be - (5 weeks ago) franck cuny - change the way we rewrite and check an existing url + 5: 3df1fd6 - (7 weeks ago) franck cuny - put id category +#+END_EXAMPLE + +You choose the revision you want to check the diff against, and you got +a (colorless) diff in your vim buffer. |
