Last active
August 29, 2015 14:01
-
-
Save fpinzn/43e5fbd9b6fda672e471 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -eo pipefail | |
# This should be a cd to a env var with the root of the notes directory | |
nhome=~/versioned/Notes/nValt | |
file=".note.searching.$RANDOM" | |
#Search the files contents | |
pushd $nhome | |
ag "$@" > $nhome/$file | |
#Search the file names | |
ls | ag "$@" >> $nhome/$file | |
#Return the names of the files with occurences uniquely | |
notes=`awk -F ":" '{print $1}' $nhome/$file | uniq` | |
#Search again but this time use stdout | |
ag --color-path '35;55' --color-line-number '34;55' --color-match '36;8;4' "$@" | |
echo -e "\nMatching Filenames:" | |
ls | ag --color-path '35;55' --color-line-number '34;55' --color-match '36;8;4' "$@" | |
echo "----" | |
popd &> /dev/null | |
selection=`select-options $notes` | |
if [ -n "$selection" ]; then | |
vim $nhome/$file | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment