mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 16:45:38 -05:00
fixup git commands with previews. now works on bash too, thanks to @joaqo
@@ -435,15 +435,15 @@ FZF-EOF"
|
||||
```
|
||||
```sh
|
||||
alias glNoGraph='git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr% C(auto)%an" "$@"'
|
||||
local _gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
|
||||
local _viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'"
|
||||
_gitLogLineToHash="echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
|
||||
_viewGitLogLine="$_gitLogLineToHash | xargs -I % sh -c 'git show --color=always % | diff-so-fancy'"
|
||||
|
||||
# fcoc_preview - checkout git commit with previews
|
||||
fcoc_preview() {
|
||||
local commit
|
||||
commit=$( glNoGraph |
|
||||
fzf --no-sort --reverse --tiebreak=index --no-multi \
|
||||
--ansi --preview $_viewGitLogLine ) &&
|
||||
--ansi --preview="$_viewGitLogLine" ) &&
|
||||
git checkout $(echo "$commit" | sed "s/ .*//")
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ fcoc_preview() {
|
||||
fshow_preview() {
|
||||
glNoGraph |
|
||||
fzf --no-sort --reverse --tiebreak=index --no-multi \
|
||||
--ansi --preview $_viewGitLogLine \
|
||||
--ansi --preview="$_viewGitLogLine" \
|
||||
--header "enter to view, alt-y to copy hash" \
|
||||
--bind "enter:execute:$_viewGitLogLine | less -R" \
|
||||
--bind "alt-y:execute:$_gitLogLineToHash | xclip"
|
||||
|
||||
Reference in New Issue
Block a user