Giter Site home page Giter Site logo

steigr / advanced-shell-history Goto Github PK

View Code? Open in Web Editor NEW

This project forked from englishm/advanced-shell-history

0.0 2.0 0.0 2.08 MB

Automatically exported from code.google.com/p/advanced-shell-history

License: Apache License 2.0

Makefile 0.16% Shell 0.33% Python 0.54% C++ 2.71% Lex 0.18% C 96.08%

advanced-shell-history's Introduction

Advanced Shell History         http://code.google.com/p/advanced-shell-history/


Save your command line history in a sqlite3 DB!


Features of this utility:
  * Retains extra command details:
    * exit code
    * start and stop times (and command duration)
    * current working directory of the command
    * session details such as tty, pid, ppid, ssh connection details
  * works with multiple shells (zsh and bash)
  * saves history into a sqlite3 database
  * provides a convenient tool to query the history database.


HOW TO BUILD:
  $ make build_c       # Builds the C++ version
  $ make build_python  # Builds the Python version
  $ make build         # Builds both versions

Notes:
  * A full build of the code from source depends on the following commands
    or utilities existing on your build system:
      - bash
      - make
      - g++ and gcc
      - curl
      - tar
      - unzip
      - sed and awk
      - flex (optional: only needed if rebuilding queries.cpp from queries.l)
  * Also recommended is sqlite3 for writing new queries interactively.
  * On a Mac, you will need to install xcode for make, g++:
      http://developer.apple.com/xcode/


HOW TO INSTALL:
  $ make install_c       # Installs the C++ version
  $ make install_python  # Installs the Python version
  $ make install         # Installs both versions


HOW TO UNINSTALL:
  $ make uninstall


HOW DOES THIS WORK:

This program operates on the assumption that your shell gives you the ability
to execute a custom operation before a prompt is redrawn on your terminal.

Bash provides the PROMPT_COMMAND environment variable while zsh gives us the
precmd environment function.  Both are repurposed by this program to log the
previous command into a local database before each new prompt is displayed.

Many people have never heard of this feature or found a great use for it.
However, if you currently DO use this feature, you can still use this program.
The code renames your existing hook and invokes it after saving the previous
command.


Caveats:
  * this is not meant to be a security auditing tool - it's for user
    convenience and meant to enhance shell builtin history.
  * for bash users, this overrides your PROMPT_COMMAND and changes the 
    default options of your builtin history.  Hopefully both are an 
    improvement.
  * for zsh users, this overrides your precmd function.  the shell script
    attempts to rename your previous precmd function and continue to hook
    into it.
  * all users will notice that the PIPESTATUS / pipestatus variables have
    been renamed to ASH_PIPESTATUS.  Because these variables are transient
    and logged, they cannot be easily restored.  Instead they are copied.
  * when you build this, the Makefile may download a version of sqlite3
    (if it's not already included in the tarball or the svn repo).
  * this potentially changes your normal shell history settings to enable
    options necessary for the magic to work.

Bugs:
  * doesn't capture exec'ed commands: example: exec rm /tmp/foo # is lost
  * the python version is about 10x slower than the C++ version

Author: [email protected] (Carl Anderson)
Last Update: 2012-08-06

advanced-shell-history's People

Contributors

barabo avatar

Watchers

 avatar  avatar

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.