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