stevemcilwain / quiver

Quiver is the tool to manage all of your tools for bug bounty hunting and penetration testing.
MIT License
206 stars 38 forks source link

Suggestion: qq-notes-search #31

Closed fullstackpotato closed 4 years ago

fullstackpotato commented 4 years ago

File: qq-notes.zsh Function: __notes()

I'm not sure if it's the way I have my notes or if it's an issue that has happened for others. I was having problems searching for a note where I'd made a mention to a specific technology within the file, but that was not part of the filename so I had to fall back to grep. Would it be possible to change the ls/grep combo in this function to a purely grep based one to search not only the titles but also the contents?

Line 16 (currently):

select note in $(ls -R --file-type ${__NOTES} | grep -ie ".md$" | grep -i "$1")

Line 16 (suggested):

select note in $(grep -rli "$1" *.md)

I believe the output should be identical in terms of formatting, but will likely need a quick test.

fullstackpotato commented 4 years ago

I went into a little bit more of a deep dive on this and found a much more visual/interactive way of searching through notes on the cli. Ideal if you use tmux and run a separate tab to read/search markdown based notes.

You can type what you want to search and let it do it's magic to simplify the list. Useful for notes in the format that you have in your secrets repo (https://github.com/stevemcilwain/secrets). This idea was taken from the tool https://github.com/srid/neuron, the moment I saw the searching and reading of notes I knew I had to replicate this as it was exactly what I wanted.

Tools required:

Code:

rg --no-heading --no-line-number --with-filename --color=always --sort path -m1 "" ${__NOTES}/*.md | fzf --tac --no-sort -d ':' --ansi --preview-window wrap --preview 'bat --style=plain --color=always ${1}'

Screenshot: image

stevemcilwain commented 4 years ago

I am doing both great suggestions. Fixing qq-notes and qq-notes-search and adding qq-notes-menu with your ripgrep/fzf/bat suggestion. Very cool, thanks! Will be in next release, 0.17, hopefully today or by this weekend.

stevemcilwain commented 4 years ago

For your first suggestion, how about also use -w with grep to search by whole word? I think that would result in less false positives and make the search more useful/practical?

fullstackpotato commented 4 years ago

Yeah that sounds like a good idea, admittedly I was getting too many returns with some searches. So that would solve it 😄

fullstackpotato commented 4 years ago

Thought I'd help out with this by learning from my mistakes (I make many!). If you reference as it is above, the window will show the full path. Better option is to fall in line with how you've done it in other functions with cd XYZ + cd -

qq-notes-menu() {
  # prob insert the logic from the function __NOTES() in qq-notes.zsh?

  cd ${__NOTES}
  rg --no-heading --no-line-number --with-filename --color=always --sort path -m1 "" *.md | fzf --tac --no-sort -d ':' --ansi --preview-window wrap --preview 'bat --style=plain --color=always ${1}'
  cd -
}