I also use it for doing interactive git rebases. I have an alias for doing a fuzzy rebase interactive (frbi):
frbi = !git rebase -i $(git log --pretty=oneline --color=always | fzf --ansi | cut -d ' ' -f1)^I made a few changes so I figured I'd post them back here in case you're interested:
pick-commit = # equivalent to your git log... cut...
rif = "!f() { rev=$(git pick-commit); [[ $rev ]] && git ri $rev~; }; f"
"rif" = "rebase interactive fzf/fuzzyfind". The function and test just makes it exit cleanly if you escape out of the filter instead of giving "fatal: invalid upstream '~'" (and I changed it from ^ to ~ because I think ~ is usually what one should use over ^, but I'm willing to be corrected). And obviously I already have 'ri' aliased to 'rebase -i'.While I'm here, here are my similar git aliases for adding, diffing, etc. files using fzf:
pick-status-files = "!f() { git status -z | xargs -0n1 | cut -c4- | fzi --print0 | xargs -0to git "$@"; }; f"
af = !git pick-status-files add
# and so on for diff, difftool, checkout, etc.
Oh, and 'fzi' (fuzzy-inline) is a small shell script that just calls: fzf --height 30% --reverse --multi "$@" rif = "!f() { rev=$(git pick-commit); [[ $rev ]] && git ri $rev~; }; f"
can just be: rif = !git pick-commit | xargs -tI% git ri %~Here's my git config with a bajillion aliases: https://github.com/kbd/setup/blob/master/HOME/.config/git/co...
Since git commands are one of the most common things to type, I alias all short git aliases like so: https://github.com/kbd/setup/blob/fd1f826a9365895b7a3b8b5c58...
(link to particular commit so line numbers stay correct). That way my workflow looks like:
$ ga (fuzzy find files to add)
$ gcm "commit message"
etc. pick-status-files = "!f() { git status -z | xargs -0n1 | cut -c4- | fzi --print0 | xargs -0to git "$@"; }; f"
can just be: pick-status-files = !git status -z | xargs -0n1 | cut -c4- | fzi --print0 | xargs -0t git
I'd recently converted it from a standalone script so I just converted it verbatim into a function.Mix it with https://github.com/rupa/z or https://github.com/skywind3000/z.lua for fuzzysearch/cd
And you can do cool scripts, like:
- search your vim edited files with highlighted preview: https://github.com/BarbUk/dotfiles/blob/master/shell/complet...
- search and open your chrome history: https://github.com/BarbUk/dotfiles/blob/master/shell/complet...