Guest User

Untitled

a guest
Jul 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. # GIT heart FZF
  2. # -------------
  3.  
  4. is_in_git_repo() {
  5. git rev-parse HEAD > /dev/null 2>&1
  6. }
  7.  
  8. fzf-down() {
  9. fzf --height 50% "$@" --border
  10. }
  11.  
  12. git-fzf-gf() {
  13. is_in_git_repo || return
  14. git -c color.status=always status --short |
  15. fzf-down -m --ansi --nth 2..,.. \
  16. --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500' |
  17. cut -c4- | sed 's/.* -> //'
  18. }
  19.  
  20. git-fzf-gb() {
  21. is_in_git_repo || return
  22. git branch -a --color=always | grep -v '/HEAD\s' | sort |
  23. fzf-down --ansi --multi --tac --preview-window right:70% \
  24. --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES |
  25. sed 's/^..//' | cut -d' ' -f1 |
  26. sed 's#^remotes/##'
  27. }
  28.  
  29. git-fzf-gt() {
  30. is_in_git_repo || return
  31. git tag --sort -version:refname |
  32. fzf-down --multi --preview-window right:70% \
  33. --preview 'git show --color=always {} | head -'$LINES
  34. }
  35.  
  36. git-fzf-gh() {
  37. is_in_git_repo || return
  38. git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always |
  39. fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \
  40. --header 'Press CTRL-S to toggle sort' \
  41. --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always | head -'$LINES |
  42. grep -o "[a-f0-9]\{7,\}"
  43. }
  44.  
  45. git-fzf-gr() {
  46. is_in_git_repo || return
  47. git remote -v | awk '{print $1 "\t" $2}' | uniq |
  48. fzf-down --tac \
  49. --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" {1} | head -200' |
  50. cut -d$'\t' -f1
  51. }
Add Comment
Please, Sign In to add comment