Skip to content

In support of Oh-My-Zsh plugin per-directory-history, I've created a crude searching mechanism, not having time to paint it, or build it to scale...

License

Notifications You must be signed in to change notification settings

cmaahs/search-directory-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Search-Directory-History

This is born from my switch to using the Oh-My-Zsh plugin for directory history, per-directory-history. Initially I was satisfied with a simple function to grep through the .directory_history to find historical commands:

function sdh() { find ~/.directory_history/**/history -exec grep "$@" {} + | cut -d';' -f2 | sort | uniq; }

Sometimes I would find that I might want to know the source directory of where I ran those commands, so I could get some additional context of the commands just prior and just after. Context is what keeps me using directory history, and I suspect was a driver for the initial concept. So I've jotted down a few things that I would like a searching tool to do, and started creating search-directory-history.

Features Map

  • Basic Search - return commands from a single keyword search
  • Intermediate Search - & and | for multi-keyword searching
  • Advanced RegEx Searching - return commands matching a passed in regex
  • Output - terse/verbose/specified fields

Cobra Command Structure

Commands: verbs, nouns adjectives

  • search
    • Verbs
      • --multiline - show entire multi-line commands
      • --startpath - start the search at a specific path: ~/.directory_history/home/myuid/src/
        • specified as /home/myuid/src
      • --searchfrom - timeframe in 4d, 3w, 2m, 1y
      • --searchduration - timeframe in 1d, 1w, 1m, 1y, starting from --searchfrom
        • defaults to --searchfrom
      • --terse
      • --context - number of context commands to display on either side of match
        • for troubleshooting/identification of context lines, a -/=/+ was used to indicate
        • if a command comes before (-), is the match (=), or is after (+)
        • basic functionality is working, would like to make it work more like diff with context
      • command line completions, looks like Cobra framework has the ability to spit out completion scripts.
      • --verbose
      • --fields - csv list of field names "date,directory,command"
      • --output - json,table,text,yaml?
  • help

About

In support of Oh-My-Zsh plugin per-directory-history, I've created a crude searching mechanism, not having time to paint it, or build it to scale...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages