An enhanced history(1) for bash

Related tags

Command-line history
Overview

history

This is a replacement for the history builtin in bash.

It has a couple of additional features that relative to the one included with bash:

  1. Consolidated shell command history from multiple terminals across multiple hosts. All history is stored in a single sqlite database. This is done without slowing down your shell or requiring a shared filesystem -- additions to the history are sent over UDP to a persistent server process.
  2. Replacement history command with enhanced search features, like temporal predicates (history --since '1 day ago') and searches for commands you performed within a specific directory (history --at .).
  3. Ctrl-r keybinding, which looks visually identical to one included with bash, but changes the behavior slightly to be more useful.
    • Ctrl-r searches the full multi-host multi-terminal database, but prefers hits from commands you performed within the current working directory.
    • The search state isn't persistent in the same way as it is with the builtin, so Ctrl-r always start searching from the same place, and after exiting out of Ctrl-r, the behavior of the up and down arrow bindings are not modified.

Usage

If you're operating inside a company cluster or university computer system and you want to consolidate history so that it's shared no matter which box you're logged into, you'll first need to pick which machine you want to act as the "server". Your login node / workstation would be a good choice.

Then just add

eval "$(/path/to/binary/history --eval myworkstation.mycompany.com)"

to your .bashrc file.

If you don't care to pool your history across multiple boxes, then you can add

Then just add

eval "$(/path/to/binary/history --eval 127.0.0.1)"

to your .bashrc file instead.

image

Inspiration / alternatives

  1. zsh-history: I copied the database schema and a lot of the CLI options from zsh-history, which is very nice. I don't use zsh, so that was the first difference. (The other difference is that zsh-history doesn't pool history from multiple machines without a shared filesystem, I think.)
  2. atuin: wow, this looks very fancy, nice job. I'm personally looking for something a bit more minimal with the ctrl-r keybindings, but this looks great.
  3. mcfly: Some cool ideas here, but I was personally not sold on the use of machine learning for this application.
  4. bash-history-sqlite: Nice and simple. I like this.
You might also like...
Simple joke randomizer from bash.org.pl made as CLI Tool in Rust.

RBashOrg Simple joke randomizer from bash.org.pl made as CLI Tool in Rust. Description Main motivation of this project was to learn basic concepts abo

🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands
🐢 Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands

Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, it provides optional and fully encrypted synchronisation of your history between machines, via an Atuin server.

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers.⛰️
git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers.⛰️

git-cliff can generate changelog files from the Git history by utilizing conventional commits as well as regex-powered custom parsers. The changelog template can be customized with a configuration file to match the desired format.

Simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history
Simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history

eva simple calculator REPL, similar to bc(1), with syntax highlighting and persistent history installation Homebrew $ brew install eva crates.io $ car

McFly - fly through your shell history
McFly - fly through your shell history

McFly - fly through your shell history McFly replaces your default ctrl-r shell history search with an intelligent search engine that takes into accou

🗄️ A simple (and safe!) to consume history of Client and Studio deployment versions.

🗄️ Roblox Version Archive A simple (and safe!) to consume history of Client and Studio deployment versions. About Parsing Roblox's DeployHistory form

Integrate Mcfly with fzf to combine a solid command history database with a widely-loved fuzzy search UI
Integrate Mcfly with fzf to combine a solid command history database with a widely-loved fuzzy search UI

McFly fzf integration Integrate McFly with fzf to combine a solid command history database with a widely-loved fuzzy search UI Features: Advanced hist

rt-history: An RT-safe history log with error checking

rt-history: An RT-safe history log with error checking This is a bounded wait-free thread synchronization primitive which allows you to record the tim

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

An enhanced version of filetime, which can set file creation time on Windows.

filetime_creation Documentation An enhanced version of filetime, which can set file creation time on Windows. Internally, this use SetFileTime Win32 A

An enhanced search engine just for Lemmy/Fediverse
An enhanced search engine just for Lemmy/Fediverse

Please Read If anyone wants to help contribute to this, please feel free to reach out to me. You can obviously find me on Lemmy, mainly https://lemmy.

Create, reorder, group, and focus workspaces easily in i3. Fully configurable with enhanced polybar modules.
Create, reorder, group, and focus workspaces easily in i3. Fully configurable with enhanced polybar modules.

Create, reorder, group, and focus workspaces fast and easily in i3. Features Focus Mode: Eliminate Distractions Enable Focus Mode: Use groups and focu

Rust version of webpack/enhanced-resolve
Rust version of webpack/enhanced-resolve

Oxc Resolver Rust port of enhanced-resolve. built-in tsconfig-paths-webpack-plugin support extending tsconfig defined in tsconfig.extends support path

A bash-like Unix shell written in Rust

Cicada Unix Shell Cicada is a simple Unix shell written in Rust. Documents Install cicada Environment Variables Cicada Builtins Completion RC File His

 Bashly - Bash CLI Framework and Generator
Bashly - Bash CLI Framework and Generator

Bashly - Bash CLI Framework and Generator Create feature-rich bash scripts using simple YAML configuration

Nvm - Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Node Version Manager Table of Contents Intro About Installing and Updating Install & Update Script Additional Notes Troubleshooting on Linux Troublesh

Is it fast? Does it have an efficient runtime? Why is Bash so slow?

Testing Languages Is it fast? Does it have an efficient runtime? Why is Bash so slow? Usage Compile and execute the run.rs file to run benchmarks. rus

Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)

WSLGit This project provides a small executable that forwards all arguments to git running inside Bash on Windows/Windows Subsystem for Linux (WSL). T

A Rust library and cli for Wordle. Inspired by Wordle in Bash
A Rust library and cli for Wordle. Inspired by Wordle in Bash

A Rust library and cli for Wordle. Inspired by Wordle in Bash

Owner
Robert T. McGibbon
Robert T. McGibbon
An enhanced search engine just for Lemmy/Fediverse

Please Read If anyone wants to help contribute to this, please feel free to reach out to me. You can obviously find me on Lemmy, mainly https://lemmy.

null 51 Jul 4, 2023
Create, reorder, group, and focus workspaces easily in i3. Fully configurable with enhanced polybar modules.

Create, reorder, group, and focus workspaces fast and easily in i3. Features Focus Mode: Eliminate Distractions Enable Focus Mode: Use groups and focu

i3-wsman 15 Sep 2, 2023
Rust version of webpack/enhanced-resolve

Oxc Resolver Rust port of enhanced-resolve. built-in tsconfig-paths-webpack-plugin support extending tsconfig defined in tsconfig.extends support path

oxc 9 Dec 30, 2023
Bashly - Bash CLI Framework and Generator

Bashly - Bash CLI Framework and Generator Create feature-rich bash scripts using simple YAML configuration

Danny Ben Shitrit 1.4k Jan 4, 2023
Nvm - Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Node Version Manager Table of Contents Intro About Installing and Updating Install & Update Script Additional Notes Troubleshooting on Linux Troublesh

nvm.sh 63.8k Jan 7, 2023
Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)

WSLGit This project provides a small executable that forwards all arguments to git running inside Bash on Windows/Windows Subsystem for Linux (WSL). T

A. R. S. 1.1k Jan 3, 2023
A handy way to handle sh/bash cli parameters

Argc A handy way to handle sh/bash cli parameters. How Argc works To write a command line program with Argc, we only need to do two things: Describe t

null 398 Jan 3, 2023
Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

is-wsl Check if the process is running inside Windows Subsystem for Linux (Bash on Windows) Inspired by sindresorhus/is-wsl and made for Rust lang. Ca

Sean Larkin 6 Jan 31, 2023
A `nix` and `nix-shell` wrapper for shells other than `bash`

nix-your-shell A nix and nix-shell wrapper for shells other than bash. nix develop and nix-shell use bash as the default shell, so nix-your-shell prin

Mercury 15 Apr 10, 2023
GPT-3 powered CLI tool to help you remember bash commands.

Rusty: GPT-3 Powered CLI Tool Convert natural language into executable commands directly from the terminal! Open source CLI tool powered by OpenAI (br

Zahid Khawaja 287 Apr 19, 2023