Skip to content

Instantly share code, notes, and snippets.

@WadeSeidule
Created September 6, 2024 14:26
Show Gist options
  • Save WadeSeidule/c4cfcb6393b27679f3afce1530042742 to your computer and use it in GitHub Desktop.
Save WadeSeidule/c4cfcb6393b27679f3afce1530042742 to your computer and use it in GitHub Desktop.
Add Fuzzy Finding to VSCode
// bind whatever keybind you want
[
{
"command": "multiCommand.runRgFAndFocusTerminal",
"key": "cmd+k"
}
]
{
"command-runner.commands": {
"rgf": "rgf; exit"
},
"multiCommand.commands": [
{
"command": "multiCommand.runRgFAndFocusTerminal",
"sequence": [
{
"command": "command-runner.run",
"args": { "command": "rgf" }
},
{
"command": "workbench.action.terminal.focus"
}
]
}
}
#!/usr/bin/env zsh
##
# Interactive search.
#
[[ -n $1 ]] && cd "$1" # go to provided folder or noop
export FZF_DEFAULT_COMMAND="rg --column --line-number --no-heading --color=always -- ''"
selected=$(
fzf \
--ansi \
--delimiter : \
--bind "f12:execute-silent:(code -g $PWD/{1..3})" \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
--preview 'bat -f --highlight-line={2} {1}' | cut -d":" -f1,2,3
)
[[ -n $selected ]] && code -g "$PWD"/"$selected"
brew install ripgrep fzf bat
code --install-extension edonet.vscode-command-runner
code --install-extension ryuta46.multi-command
# change to ~/.bash_profile or ~/.bashrc if using bash
echo 'export FZF_DEFAULT_OPTS="--history=$HOME/.fzf-history"' >> ~/.zshrc
# save rgf.sh to local machine and set variable with path. Defaults below to ~/rgf.sh
RGF_BIN=$HOME/rgf.sh
cat $RGF_BIN > /usr/local/bin/rgf
# After opening a new terminal rgf command is globally available
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment