Skip to content

Instantly share code, notes, and snippets.

@Frosthaven
Created February 21, 2025 12:59
Show Gist options
  • Select an option

  • Save Frosthaven/eb60410297b319fa8253991c77d08cc6 to your computer and use it in GitHub Desktop.

Select an option

Save Frosthaven/eb60410297b319fa8253991c77d08cc6 to your computer and use it in GitHub Desktop.
[S]earch [F]iles (sf) command - leveraging fzf and bat
# sf [s]earch [f]iles command (sf)
# this will use the output of the fzf command to open the file in nvim. You can
# - change the editor launch command to whatever you want.
# - see: https://github.com/junegunn/fzf
# - see: https://github.com/sharkdp/bat
function sf {
$file = fzf --preview "bat --color=always {}" --preview-window=right:50%:wrap --height 50% --border --prompt="Search Files: " --query="$args"
if ($file) {
nvim $file # or with your editor of choice
}
}
@Frosthaven
Copy link
Author

Frosthaven commented Feb 21, 2025

You can do this on whatever os or shell you want. This is just an example under Windows + PowerShell.

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