gory is a CLI tool written in Go that simulates the behavior of the shell history command, with added features to simplify searching and interactively executing past commands.
- Reads commands directly from the user’s
~/.bash_historyor~/.zsh_historyfile. - Automatically detects whether you're using Bash or Zsh.
- Allows searching for commands containing a specific string.
- Allows limiting the number of returned commands.
- Enables interactive execution of a selected command after a terminal confirmation prompt.
You can install gory by building the Go project:
go install github.com/rojack96/gory/cmd/gory@latestMake sure your $GOPATH/bin is in your PATH.
-
-s,--search <string>Search and display all commands in history that contain<string>. -
-n,--number <num>Limit the number of displayed commands to<num>. -
--read-onlyNot execute commands, just show them. -
-m,--modifyAllow the user to modify the selected command.
-
Show the last 10 commands:
gory -n 10
-
Search all commands containing
docker:gory -s docker
-
Search and show up to 5 commands containing
git:gory -s git -n 5
gory reads from ~/.bash_history or ~/.zsh_history, depending on the active shell.
To ensure your shell history is up to date before using
gory, it is recommended to run:
For Bash:
history -aFor Zsh:
fc -WAfter displaying matching commands, gory will ask if you want to execute one of them via a simple confirmation prompt.
If you confirm, the selected command will be executed directly in your terminal.
Pull requests and issues are welcome!
This project uses the following third-party libraries:
- charmbracelet/huh - MIT License