Skip to content

zveinn/gistory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gistory - Interactive Bash History Search

A fast, interactive replacement for bash's Ctrl+R reverse history search, built with Go and tview.

image

Features

  • Fuzzy search: Type anywhere in the command to find matches
  • Interactive TUI: Real-time filtering as you type
  • Deduplication: Shows only unique commands (most recent first)

Installation

Download pre-built binary

  1. Go to the releases page
  2. Download the archive for your OS and architecture
  3. Extract and install:
tar xzf gistory_*.tar.gz
sudo mv gistory /usr/local/bin/

Build from source

go build -o gistory
sudo mv gistory /usr/local/bin/

Or install to your local bin:

go build -o gistory
mkdir -p ~/bin
mv gistory ~/bin/
# Make sure ~/bin is in your PATH

Usage

Simply run:

gistory

Keyboard shortcuts

  • Type: Filter commands with fuzzy search
  • Enter: Select current command (prints to stdout)
  • Up/Down or Ctrl+P/Ctrl+N: Navigate through results
  • Esc: Cancel and exit

Bash Integration

To replace Ctrl+R with gistory, add this to your ~/.bashrc:

Option 1: Execute immediately (recommended)

# Bind Ctrl+R to gistory - auto-execute selected command
bind -x '"\C-r": __gistory'

__gistory() {
    history -w
    local selected
    selected=$(gistory)
    if [ -n "$selected" ]; then
        history -s "$selected"  # Add to history
        eval "$selected"         # Execute immediately
    fi
}

Option 2: Insert into command line (edit before running)

# Bind Ctrl+R to gistory - insert into readline buffer
bind -x '"\C-r": __gistory'

__gistory() {
    history -w
    local selected
    selected=$(gistory)
    if [ -n "$selected" ]; then
        READLINE_LINE="$selected"
        READLINE_POINT=${#READLINE_LINE}
    fi
}

After adding this, reload your bashrc:

source ~/.bashrc

Now pressing Ctrl+R will launch gistory instead of the default reverse search!

How it works

  1. Reads commands from ~/.bash_history
  2. Deduplicates commands (keeps most recent)
  3. Provides interactive fuzzy search interface
  4. Outputs selected command to stdout
  5. Bash integration either executes it immediately or inserts it into your command line

Requirements

  • Go 1.16 or higher (for building)
  • Bash with bind -x support (most modern versions)
  • Terminal with color support

License

MIT

About

A better interactive reverse bash history search

Resources

License

Stars

Watchers

Forks

Packages

No packages published