Skip to content

Command line app for quick search through the command history of shell

Notifications You must be signed in to change notification settings

webus/gohistgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gohistgrep

Command line app for quick search through the command history of shell

Sometime we need to see the command that we ran for a very long time. In the command shell, bash is used for this file .bash_history. The history in this file to be kept for a very long time. So I had the idea to store the history of my shell commands forever!

Then I found somewhere on the internet this script:

HISTFILESIZE=2000
mkdir -p $(dirname  $HISTFILE)
export HISTFILE="$HOME/.history/$(date -u +%Y/%m/%d.%H.%M.%S)_${HOSTNAME_SHORT}_$$"
histgrep()
{
  grep -r "$@" ~/.history
  history | grep "$@"
}

Just add these lines to your .bashrc file. And that's all :)

Now you will have to store the history of your commands carefully. So you have a new feature in Bash. You can write histgrep continue to specify a part of your command and Bash will run on all history files and show matches!

Much time has passed and I have accumulated my command history in Bash for 3 years! Search vehicles grep was very long...

So I decided to write this small tool in Golang. This app reads all files of your history and stores data from them in sqlite database. Next command works only with this database, so search through the command history is very fast!

Additionally, this app is able to count popular commands in history, which makes search more relevant :) Your little Google right in your console :)

About

Command line app for quick search through the command history of shell

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages