Giter Club home page Giter Club logo

duiker's Introduction

duiker

travis

Automatically index your shell history in a full-text search database. Magic!

Features

  • Uses SQLite3's excellent FTS4 extension to provide full-text search.
  • Respects HISTTIMEFORMAT if set.

Requirements

  • Bash

Install

Download the latest release and extract it somewhere on your $PATH.

Alternatively, install Duiker from source. To build the package you will need:

Simply run:

make install

Setup

Import your existing shell history:

HISTTIMEFORMAT='%s ' history | duiker import -

Configuration

If you want to automatically import your shell history on-the-fly, you can add duiker import to your PROMPT_COMMAND [1].

Run duiker magic to print a shell snippet that automatically imports your last command into Duiker:

duiker magic

Configure this shell snippet as part of your PROMPT_COMMAND. Run duiker magic --help for an example.

Searching

Duiker indexes your shell history in an SQLite3 full-text search table.

You can use any MATCH [2] expression to search the database:

$ duiker search git
2017-04-13 15:50:02         git staged
2017-04-13 15:50:14         git commit -a
2017-04-13 15:55:07         git diff
$ duiker search '(git OR fossil) diff'
2017-04-27 15:15:01         git diff
2017-04-27 15:15:49         git diff
2017-04-28 14:49:19         fossil diff
2017-04-28 14:53:09         fossil diff src/main.rs
$ duiker search 'sqlite*'
2017-03-04 19:00:42         sqlite3 db.sqlite
2017-03-04 19:13:11         rm db.sqlite

Limitations

Duiker only supports Bash at present. Pull requests for other shells welcome.

License

MIT

[1]https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html#Controlling-the-Prompt
[2]https://sqlite.org/fts3.html#full_text_index_queries

duiker's People

Contributors

benwebber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rohith295

duiker's Issues

`ValueError:` on `history | duiker import -`

My Specs

  • MacOS 10.12.4
  • Homebrew:
    Homebrew 1.1.13
    Homebrew/homebrew-core (git revision ad49cc; last commit 2017-04-28)
    

Issue

When running history | duiker import -, an exception is thrown:

Traceback (most recent call last):
  File "/Users/kris/bin/duiker", line 11, in <module>
    sys.exit(main())
  File "/Users/kris/.virtualenvs/duiker/lib/python3.6/site-packages/duiker.py", line 307, in main
    args.func(args)
  File "/Users/kris/.virtualenvs/duiker/lib/python3.6/site-packages/duiker.py", line 179, in handle_import
    for command in duiker.import_file(args.histfile):
  File "/Users/kris/.virtualenvs/duiker/lib/python3.6/site-packages/duiker.py", line 94, in import_file
    command = self._parse_line(line)
  File "/Users/kris/.virtualenvs/duiker/lib/python3.6/site-packages/duiker.py", line 107, in _parse_line
    timestamp = dt.strptime(remainder[:self._hist_offset], self.hist_time_format)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_strptime.py", line 354, in _strptime
    (bad_directive, format)) from None
ValueError: 'F' is a bad directive in format '%F %T '

Reproduce

  1. Set your bash HISTTIMEFORMAT='%F %T'

Workaround

You can avoid this error by setting HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.