diff options
author | David Morgan <djm_uk@protonmail.com> | 2021-01-06 14:04:11 +0000 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2021-01-06 14:04:11 +0000 |
commit | a2629cfd8c142ee7dcc22a28020e3556628535b0 (patch) | |
tree | 7d9c37cdec211dd2fd5ddaa2894933b0f0bfcc17 /fzf-git/functions.sh | |
parent | 782c3991d8ff830820a2b2c0e84de9204e9dff33 (diff) | |
download | dotfiles-a2629cfd8c142ee7dcc22a28020e3556628535b0.tar.gz |
Add zsh/zprezto, starship and neovim config
Diffstat (limited to 'fzf-git/functions.sh')
-rw-r--r-- | fzf-git/functions.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/fzf-git/functions.sh b/fzf-git/functions.sh new file mode 100644 index 0000000..c1f6fb7 --- /dev/null +++ b/fzf-git/functions.sh @@ -0,0 +1,52 @@ +# GIT heart FZF +# ------------- + +is_in_git_repo() { + git rev-parse HEAD > /dev/null 2>&1 +} + +fzf-down() { + fzf --height 50% "$@" --border +} + +_gf() { + is_in_git_repo || return + git -c color.status=always status --short | + fzf-down -m --ansi --nth 2..,.. \ + --preview '(git diff --color=always -- {-1} | sed 1,4d; cat {-1}) | head -500' | + cut -c4- | sed 's/.* -> //' +} + +_gb() { + is_in_git_repo || return + git branch -a --color=always | grep -v '/HEAD\s' | sort | + fzf-down --ansi --multi --tac --preview-window right:70% \ + --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | + sed 's/^..//' | cut -d' ' -f1 | + sed 's#^remotes/##' +} + +_gt() { + is_in_git_repo || return + git tag --sort -version:refname | + fzf-down --multi --preview-window right:70% \ + --preview 'git show --color=always {} | head -'$LINES +} + +_gh() { + is_in_git_repo || return + git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | + fzf-down --ansi --no-sort --reverse --multi --bind 'ctrl-s:toggle-sort' \ + --header 'Press CTRL-S to toggle sort' \ + --preview 'grep -o "[a-f0-9]\{7,\}" <<< {} | xargs git show --color=always | head -'$LINES | + grep -o "[a-f0-9]\{7,\}" +} + +_gr() { + is_in_git_repo || return + git remote -v | awk '{print $1 "\t" $2}' | uniq | + fzf-down --tac \ + --preview 'git log --oneline --graph --date=short --pretty="format:%C(auto)%cd %h%d %s" {1} | head -200' | + cut -d$'\t' -f1 +} + |