Skip to content

Instantly share code, notes, and snippets.

@knoxknox
Last active April 20, 2020 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knoxknox/5081b7e283170060139673bcb0138a59 to your computer and use it in GitHub Desktop.
Save knoxknox/5081b7e283170060139673bcb0138a59 to your computer and use it in GitHub Desktop.
#!/bin/bash
##
# Interactive search.
# Usage: `ff` or `ff <folder>`.
#
[[ -n $1 ]] && cd $1 # go to provided folder or noop
RG_DEFAULT_COMMAND="rg -i -l --hidden --no-ignore-vcs"
selected=$(
FZF_DEFAULT_COMMAND="rg --files" fzf \
-m \
-e \
--ansi \
--phony \
--reverse \
--bind "ctrl-a:select-all" \
--bind "f12:execute-silent:(subl -b {})" \
--bind "change:reload:$RG_DEFAULT_COMMAND {q} || true" \
--preview "rg -i --pretty --context 2 {q} {}" | cut -d":" -f1,2
)
[[ -n $selected ]] && subl $selected # open multiple files in editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment