Skip to content

Instantly share code, notes, and snippets.

@preaction
Created February 22, 2019 17:03
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 preaction/e28042ddd20c0e6f62e26efb5f5db463 to your computer and use it in GitHub Desktop.
Save preaction/e28042ddd20c0e6f62e26efb5f5db463 to your computer and use it in GitHub Desktop.
Useful shell functions / scripts
vack() {
# Takes a keyword as an argument, acks current directory, opens a vim session
# with a tab for each file with a match found, and puts the keyword in the @/
# register, so that you can `n` through matches.
my_search=$(ack -l "$1")
if [[ -z $my_search ]]
then
echo "No results found for $1"
else
args=(--cmd "let @/=\"$1\"" -p )
vim "${args[@]}" $(echo $my_search)
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment