Better Shell History Search
23 comments
·March 25, 2025ackyshake
akimbostrawman
Interesting approach. Im so lazy I would just create a alias with the commands initials so "sur" but I guess that can get confusing if there are too many.
ackyshake
For sure. Personally, I avoid shortened aliases like that. I regularly need to use barebones systems so I wouldn't like something like "ll" (`ls -l`) or "gst" (`git status`) becoming muscle memory. Most of my aliases I do define are proper english words.
BeeOnRope
I use Atuin and like it a lot, and sync history across hosts.
However, the fuzzy search in Atuin is worse than fzf, which was a downgrade. It just has less effective heuristics/scoring, e.g. it might find the individual letters of a short command scattered in a command that had a long base64 input or something.
bayesianbot
You can use ' to do exact match, like 'docker
https://docs.atuin.sh/configuration/config/#fuzzy-search-syn...
khimaros
it's worth noting that atuin is now available in debian testing/trixie, so it will eventually be an apt install away for new stable installs.
yb303
I have my own solution that I've been using for many years — I record all my bash history.
Bash has a hook (cannot remember the name on my phone) that is called on every command.
It's easy enough to write into a file the command together with the directory and git branch.
Then I can grep it with a bash function that colors the dir and branch in the output.
It does not replace ctrl-r but it's a great addition especially when running multiple sessions and bash saving just the last one
rascul
> Bash has a hook (cannot remember the name on my phone) that is called on every command.
$PROMPT_COMMAND
https://www.gnu.org/software/bash/manual/html_node/Bash-Vari...
bandie91
> Bash has a hook (cannot remember the name on my phone) that is called on every command.
trap 'echo "$BASH_COMMAND" >> ~/.bash_history_extra' DEBUG
this runs before commands, not after the whole command line (before prompt is displayed).
my personal bash history tweak suit is based on this. with a load of complexity of course, because the DEBUG trap is also triggered before each PROMPT_COMMAND commands and on every simple command within the issued command line. so the above example would record each command of a pipeline separately.
7e
Dupe of https://news.ycombinator.com/item?id=43476793
Decades have passed and HN still can’t automatically dedup submissions.
js2
Usually it does de-dupe any submission with "significant attention", but I'm not sure what the threshold for that is.
I'd think the submissions from two days ago (206 points, 93 comments) would have qualified. (It's the exact same URL so that's not why it wasn't de-duped either.)
https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
joatmon-snoo
Pretty sure dedupe is done manually by u/dang.
js2
Yes, he can manually merge duplicate submissions and their comments.
But there's times when I've submitted items that are dupes and it just takes me to the recent submission and adds an upvote. Now here's something weird: I just tested this by submitting the URL from this submission with the same title and it immediately took me to the discussion from two days ago.
So I'm really confused how this dupe got through.
yb303
Why dedup? Old forgotten things are as good as new :)
usr1106
2 years might be OK, but not 2 days as in this case.
montag
I'm ok with dupes. But cross-linking should at least be automatic.
khimaros
i use the open source Glider frontend on Android and it shows related posts automatically. recommended.
efilife
Isn't this intentional? How would deduping work?
kyyol
Have been using Atuin for a couple (few?) years, it's great! How many others are using it too? I'm curious what everyone's tool of choice for shell search is!
khimaros
happy user here. atuin coupled with z has made it so much easier to be productive across multiple projects (especially less frequently accessed ones). just "z project" and then Ctrl+r twice to see the most recently used commands in that directory.
doawoo
I’ve always just done
alias hst=“history | fzf”
Not nearly as feature full but the simplicity of it makes me happy :)joatmon-snoo
An unfortunate problem with using awk: there are three different versions of awk, and it is frighteningly easy to use a feature that exists on one but not other.
(source: I have written unit tests against different versions of awk. That was... unpleasant.)
wonger_
Aka using fzf/skim with a script for relative timestamps; and some reasons to avoid atuin or fish.
Good to know about skim as an fzf alternative.
I use bog-standard zsh without any plugins or any of the fancy stuff, but one of the most useful tricks I use is to leverage interactive comments. If I have a long command I know I run will frequently, I 'tag' them at the end by a shell comment[1].
So for example, I have one that I use to run software updates:
I have a similar one without the `--restart` option that I tag with `:norestart` instead, but you get the idea—I put related commands under a common term.Then I can just use the ctrl-r builtin keybinding, type `:system` and cycle through system related commands, or go exactly to the command I want. The beauty of this is that it also works in bash and systems I remote into (which I frequently need to do at work), without any extra plugins required.
[1]: interactive comments are disabled by default in zsh, but can be enabled with `setopt interactive_comments`