Skip to content

Instantly share code, notes, and snippets.

@ben-albrecht
Last active August 27, 2019 15:58
Show Gist options
  • Save ben-albrecht/dbc5fde1913203519668cd41b997cf90 to your computer and use it in GitHub Desktop.
Save ben-albrecht/dbc5fde1913203519668cd41b997cf90 to your computer and use it in GitHub Desktop.
# 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
@ben-albrecht
Copy link
Author

Requires brew install rg fzf on OSX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment