4 ms·
Better Shell History Search
- wonger_ 2y agoAka 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.
- yb303 2y agoI 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 2y ago> 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-Variables.html#index-PROMPT_005fCOMMAND https://www.gnu.org/software/bash/manual/html_node/Bash-Vari...
- bandie91 2y ago> 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 2y agoDupe of https://news.ycombinator.com/item?id=43476793 https://news.ycombinator.com/item?id=43476793 Decades have passed and HN still can’t automatically dedup submissions.
- yb303 2y agoWhy dedup? Old forgotten things are as good as new :)
- usr1106 2y ago2 years might be OK, but not 2 days as in this case.
- efilife 2y agoIsn't this intentional? How would deduping work?
- js2 2y agoUsually 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&query=by%3Adang%20attention%20dup&sort=byDate&type=comment https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
- joatmon-snoo 2y agoPretty sure dedupe is done manually by u/dang.
- js2 2y agoYes, 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.
- BeeOnRope 2y agoI 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.
- khimaros 2y agoit'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.
- bayesianbot 2y agoYou can use ' to do exact match, like 'docker https://docs.atuin.sh/configuration/config/#fuzzy-search-syntax https://docs.atuin.sh/configuration/config/#fuzzy-search-syn...
- BeeOnRope 2y agoYes, I rely heavily on ^ and ' in antuin, though that's partly to workaround the relatively poor fuzzy search (in fzf I never even needed those).
- kyyol 2y agoHave 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! https://github.com/atuinsh/atuin https://github.com/atuinsh/atuin
- khimaros 2y agohappy 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.
- joatmon-snoo 2y agoAn 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.)
- doawoo 2y agoI’ve always just done alias hst=“history | fzf” Not nearly as feature full but the simplicity of it makes me happy :)
- ackyshake 2y agoI 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: softwareupdate --include-config-data --install --all --restart # system:update:restart 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`
- akimbostrawman 2y agoInteresting 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 2y agoFor 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.
- bandie91 2y agoshameless plug: http://sysop.user.uucp.hu/bash-extended-history/content.md http://sysop.user.uucp.hu/bash-extended-history/content.md
- bandie91 2y agohttp://sysop.user.uucp.hu/bash-extended-history/ http://sysop.user.uucp.hu/bash-extended-history/