Skip to content

Instantly share code, notes, and snippets.

@AeroCross
Last active August 31, 2018 08:55
Show Gist options
  • Save AeroCross/5ca7d2a47e21a9b51835f6c382f56ff4 to your computer and use it in GitHub Desktop.
Save AeroCross/5ca7d2a47e21a9b51835f6c382f56ff4 to your computer and use it in GitHub Desktop.
Recursively and incrementally search a directory and open the file in Visual Studio Code
# depends on fzf and ag
function search_file_contents() {
ag --nobreak --numbers --column --noheading . | \
fzf --exact --delimiter=: --nth=2.. | \
cut -d : -f 1-2 | \
xargs -n 1 code -g $1
}
alias f=search_file_contents
# without leaving fzf (pressing enter)
function search_file_contents() {
ag --nobreak --numbers --column --noheading . | \
fzf --exact --delimiter=: --nth=2.. --bind 'enter:execute#echo {} | cut -d : -f 1-3 | xargs -n 1 code -g $1#'
}
alias f=search_file_contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment