From 5496127fc5719ee8acef843464cb1b54f8b9d3b5 Mon Sep 17 00:00:00 2001 From: Noah Masur Date: Wed, 25 Nov 2020 19:27:07 -0500 Subject: [PATCH] some fzf working --- fish.configlink/functions/gittools.fish | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fish.configlink/functions/gittools.fish b/fish.configlink/functions/gittools.fish index 56dc60a..b142540 100644 --- a/fish.configlink/functions/gittools.fish +++ b/fish.configlink/functions/gittools.fish @@ -4,10 +4,23 @@ function gittools function git-fuzzy-branch -a header set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n') - set -l branch (git branch --format "%(refname:short)" | eval "fzf $FZF_DEFAULT_OPTS --header='On $current, $header'") + set -l branch (git branch --format "%(refname:short)" | fzf --height 50% --header='On $current, $header' --preview-window right:70% --preview 'git log {} --color=always --pretty=oneline | cut -d" " -f2-') and echo $branch end + function git-commits + set commitline (git log --pretty=oneline | fzf --height 50% --preview 'git show --color=always (echo {} | cut -d" " -f1)') + and set commit (echo $commitline | cut -d" " -f1) + and git checkout $commit + end + + function git-branch + set branch (git branch --format "%(refname:short)" | fzf --height 50% --preview 'git log {} --pretty=oneline') + set commitline (git log --pretty=oneline | fzf --height 50% --preview 'git show --color=always (echo {} | cut -d" " -f1)') + and set commit (echo $commitline | cut -d" " -f1) + and git checkout $commit + end + function git-checkout-fuzzy set branch (git-fuzzy-branch "checkout branch...") and git checkout $branch