Configs2026年7月23日·1 分钟阅读

hstr — Interactive Shell History Search with Suggestions

A C-based tool that replaces the default Ctrl-R reverse search with a visual, filterable history browser supporting favorites and frequency-ranked results.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
hstr Overview
直接安装命令
npx -y tokrepo@latest install c09bc9e9-86b7-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

hstr (originally hh) is a shell history browser that replaces the default Ctrl-R reverse-search with a full-screen interactive interface. It ranks commands by frequency, recency, and length, and lets you bookmark frequently used commands for quick access.

What hstr Does

  • Displays shell history in a scrollable, searchable full-screen interface
  • Ranks commands using a combination of frequency, recency, and length metrics
  • Supports three view modes: ranked, chronological, and favorites
  • Allows bookmarking commands as favorites for instant recall
  • Removes duplicate and blacklisted entries to keep history clean

Architecture Overview

hstr is written in C and reads directly from the shell's history file (~/.bash_history or equivalent). It builds an in-memory index of commands, scores them using a weighted ranking algorithm, and renders the UI using ncurses. The favorites list is stored in ~/.hstr_favorites. hstr hooks into the shell by binding to Ctrl-R via a shell function.

Self-Hosting & Configuration

  • Install via Homebrew, apt, pacman, or build from source with make
  • Run hstr --show-configuration to generate the shell integration snippet
  • Configure the HSTR_CONFIG environment variable to set sorting, colors, and blacklist
  • Favorites are stored in ~/.hstr_favorites as a plain text file
  • Blacklisted commands (e.g., passwords) can be excluded from history display

Key Features

  • Three display modes: ranked by frequency, raw chronological order, and favorites
  • Substring and regex search within history entries
  • Delete individual history entries from within the interface
  • Case-insensitive search by default with optional case-sensitive mode
  • Minimal resource usage with instant startup time

Comparison with Similar Tools

  • fzf + Ctrl-R — fzf provides fuzzy history search but requires shell integration setup; hstr is purpose-built for history
  • Atuin — syncs history across machines with SQLite and encryption; hstr is local-only and simpler
  • McFly — uses a neural network for ranking; hstr uses a simpler frequency/recency algorithm
  • zsh-autosuggestions — inline suggestions while typing; hstr is an interactive full-screen browser
  • bash built-in Ctrl-R — basic reverse search one result at a time; hstr shows all matches at once

FAQ

Q: Does hstr modify my shell history file? A: hstr reads the history file but does not modify it automatically. You can delete individual entries from within hstr, which updates the history.

Q: Does it work with zsh? A: Yes. hstr supports both bash and zsh, with configuration snippets for each shell.

Q: What does the ranking algorithm consider? A: Commands are scored based on how often they appear (frequency), how recently they were used (recency), and command length (shorter commands rank slightly higher for common operations).

Q: Can I sync favorites across machines? A: The favorites file is a plain text file at ~/.hstr_favorites. You can sync it using dotfile managers or cloud storage.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产