Last active
August 27, 2019 15:58
-
-
Save ben-albrecht/dbc5fde1913203519668cd41b997cf90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source a file if it exists | |
function source_if_exists { | |
if [ -f "$1" ]; then | |
. "$1" | |
fi | |
} | |
# Returns whether the given command is executable or aliased. | |
function _has() { | |
return $(which $1 >/dev/null ) | |
} | |
# | |
# Set up ctrl-r to fuzzy search over bash history using ripgrep | |
# | |
# fzf via Homebrew | |
# brew --prefix fzf == /usr/local/opt/fzf | |
source_if_exists /usr/local/opt/fzf/shell/key-bindings.bash | |
source_if_exists /usr/local/opt/fzf/shell/completion.bash | |
# fzf + rg configuration | |
if _has fzf && _has rg; then | |
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null' | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
bind -x '"\C-p": vim $(fzf);' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires
brew install rg fzf
on OSX