Skip to content

Commit

Permalink
Preview the current commit when searching git log (#26)
Browse files Browse the repository at this point in the history
When searching git log, preview the commit for the current line with git show. Output is colorized. Also, since the preview pane eats up a lot of space, trimmed git log lines by using a shorter date format and removing a space used for padding.
  • Loading branch information
PatrickF1 authored Sep 8, 2020
1 parent ed9c34a commit 1f798ea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A plugin that integrates [fzf](https://github.com/junegunn/fzf) into your [fish]
![git status select](/images/git_status_select.png)

> Search the current repository's **git log** - `Ctrl+Alt+l` (l for log, Alt to prevent overriding clear screen)
> Search and preview the current repository's **git log** - `Ctrl+Alt+l` (l for log, Alt to prevent overriding clear screen)
![git log search](/images/git_log_search.png)

Expand Down
4 changes: 2 additions & 2 deletions functions/__fzf_search_git_log.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ function __fzf_search_git_log --description "Search the git log of the current g
set selected_log_line (
# see documentation for git format placeholders at https://git-scm.com/docs/git-log#Documentation/git-log.txt-emnem
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
git log --color=always --format=format:'%C(bold blue)%h%C(reset) - %C(cyan)%aD%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' | \
fzf --ansi --tiebreak=index
git log --color=always --format=format:'%C(bold blue)%h%C(reset) - %C(cyan)%as%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' | \
fzf --ansi --tiebreak=index --preview='git show --color=always (string split --max 1 " " {})[1]'
)
if test $status -eq 0
set abbreviated_commit_hash (string split --max 1 " " $selected_log_line)[1]
Expand Down
Binary file modified images/git_log_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1f798ea

Please sign in to comment.