diff options
| author | Robert Günzler <r@gnzler.io> | 2020-04-10 13:53:57 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-04-10 13:53:57 +0200 |
| commit | 32c8cbe88031c17adb5a918d462de851961916d4 (patch) | |
| tree | 878d99cc88b4635635187e99959a3a4bf355bf4b /bin/fzfez | |
| parent | 17af04ced8632014cc6c40e08558febb1d7ce23f (diff) | |
Add bin/fzfez
Diffstat (limited to 'bin/fzfez')
| -rwxr-xr-x | bin/fzfez | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/bin/fzfez b/bin/fzfez new file mode 100755 index 0000000..1191052 --- /dev/null +++ b/bin/fzfez @@ -0,0 +1,66 @@ +#!/bin/sh + +set -e + +exec_hist=/tmp/fzf-interactive_exec-hist +if [ ! -f "$exec_hist" ]; then + touch "$exec_hist" +fi + +case "$1" in + exec) + uniq "$exec_hist" \ + | grep -v '^$' \ + | fzf \ + --header 'Select or enter a command, {} is previous selection' \ + --bind 'tab:replace-query' \ + --bind 'enter:print-query' \ + | tee -a $exec_hist \ + | sed "s#{}#$2#g" \ + | sh -s + exit $? + ;; + + git-branches) + git rev-parse HEAD > /dev/null 2>&1 || exit 1 + git branch -a --sort=refname --format='%(refname)' \ + | $0 \ + --border --ansi --no-sort --reverse --tac \ + --header 'Press ctrl-s to toggle sort' \ + --bind 'ctrl-s:toggle-sort' \ + --preview 'git log --oneline --graph --date=short --color=always {} | head -${LINES}' \ + --preview-window right:70% \ + | cut -d' ' -f1 \ + | sed 's#^refs/##' \ + | sed 's#^remotes/##' \ + | sed 's#^heads/##' + ;; + + git-tags) + git rev-parse HEAD > /dev/null 2>&1 || exit 1 + git tag --sort -version:refname \ + | $0 \ + --border --no-sort \ + --preview 'git show --color=always {} | head -${LINES}' \ + --preview-window right:70% \ + | cut -d' ' -f1 \ + | sed 's#^refs/##' \ + | sed 's#^remotes/##' \ + | sed 's#^heads/##' + ;; + + rg) + shift + rg $@ --files-with-matches \ + | $0 \ + --border \ + --header 'Press ctrl-s to toggle sort' \ + --bind 'ctrl-s:toggle-sort' \ + --preview "rg $* --color=always --no-filename --glob='{}' --context=5 --line-number" + ;; + + *) + fzf \ + --bind "ctrl-x:execute(${0} exec {})" \ + "$@" ;; +esac |