Created
February 22, 2019 17:03
-
-
Save preaction/e28042ddd20c0e6f62e26efb5f5db463 to your computer and use it in GitHub Desktop.
Useful shell functions / scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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