search-directory-history

command module
v0.0.0-...-03818b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

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

Documentation

Overview

Copyright © 2020 Christopher J. Maahs <cmaahs@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL