5 ms·
highly recommended for fellow ctrl-r addicts: https://github.com/junegunn/fzf https://github.com/junegunn/fzf
by tapoxi 7y ago
highly recommended for fellow ctrl-r addicts: https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- umvi 7y agoThese ones are pretty good too: https://github.com/cantino/mcfly https://github.com/cantino/mcfly https://github.com/dvorka/hstr https://github.com/dvorka/hstr
- graton 7y agoI also recommend FZF. Really very handy for doing CTRL-R searches. 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)^
- kbd 7y agoThis is a great idea, thanks for it! I've done similar things with using fzf to git add, git diff, and so on, but I hadn't thought of using it to pick a commit to rebase from. 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 "$@"
- graton 7y agoThanks for that. I like your improvements to my idea too! :)
- kbd 7y agoYay. Btw, one more improvement. TIL xargs will skip blank inputs (depending on bsd/gnu xargs, flags etc...), so my version above: rif = "!f() { rev=$(git pick-commit); [[ $rev ]] && git ri $rev~; }; f" can just be: rif = !git pick-commit | xargs -tI% git ri %~
- girishso 7y agoThat looks great. Do you have your dotfiles shared by any chance?
- kbd 7y agoSure: https://github.com/kbd/setup https://github.com/kbd/setup Here's my git config with a bajillion aliases: https://github.com/kbd/setup/blob/master/HOME/.config/git/config 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/fd1f826a9365895b7a3b8b5c585e5154863d87cd/HOME/bin/shell_sources/aliases.sh#L126 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.
- kbd 7y agoCan't edit this anymore. 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.
- barbuk 7y agofzf is the most fun and productive tool added in my dotfiles in recent years. Mix it with https://github.com/rupa/z https://github.com/rupa/z or https://github.com/skywind3000/z.lua 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/completion#L136 https://github.com/BarbUk/dotfiles/blob/master/shell/complet... - search and open your chrome history: https://github.com/BarbUk/dotfiles/blob/master/shell/completion#L155 https://github.com/BarbUk/dotfiles/blob/master/shell/complet...