News for hackers. Stuff that matters.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by bwhaley on Thursday March 26, 2026 @08:57AM (#47529862)
Once you start using CTRL+r, you may find that you never reach for up arrow again.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by pavel_lishin on Thursday March 26, 2026 @09:59AM (#47530546)
I'm familiar with ctrl-r, but I still very much like the up-arrow behavior described by that commenter.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by flir on Thursday March 26, 2026 @11:42AM (#47531892)
Looking at it from a "law of least surprise" angle, it's exactly how it should behave.

"I typed 'cd di↑' and you're giving me 'pwd'??"

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by dotancohen on Thursday March 26, 2026 @06:38PM (#47536733)
What I love about the default Bash Crtl-C behaviour is that once a command has been located, the bash history is moved to the history of that command, until Enter is pressed.

  $ a
  bash: a: command not found
  $ b
  bash: b: command not found
  $ c
  bash: c: command not found
  $ d
  bash: d: command not found
  $ <CTRL-R> b <UP>
  $ a
That's great if I don't remember which command I was experimenting with, but I do know other commands that I did around that time (usually a file that I edited with VIM).
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by noisy_boy on Thursday March 26, 2026 @11:38AM (#47531853)
export EDITOR=vi and then hitting Esc puts you into vi mode; k, j to move up/down through history or pressing / to search etc including using regex is all available.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by BeetleB on Thursday March 26, 2026 @11:07AM (#47531432)
There is a difference, I believe. Doesn't Ctrl+r do a substring search instead?
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by imglorp on Thursday March 26, 2026 @12:54PM (#47532832)
Yes it's different: it will match anywhere in the previous command lines.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by kuschkufan on Thursday March 26, 2026 @09:10AM (#47530004)
And once you want to one-up this look into fzf.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by nidnogg on Thursday March 26, 2026 @09:31AM (#47530254)
And once you get tired of fzf and want something better, you reach for https://atuin.sh.

Completely transformed all of my workflows

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by seedie on Thursday March 26, 2026 @10:32AM (#47530942)
From the atuin.sh website

> Sync your shell history to all of your machines

I think of my shell history as very machine specific. Can you give some insights on how you benefit from history sync? If you use it.

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by Cyphus on Thursday March 26, 2026 @10:41AM (#47531048)
That feature is entirely optional and disabled by default. Atuin stores your shell history locally in a sqlite db regardless of whether you choose to sync it. I thought fzf was fast, but atuin makes it look slow by comparison.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by foobarian on Thursday March 26, 2026 @10:45AM (#47531103)
Same, I find shared history not very useful.

However what I do find useful is eternal history. It's doable with some .bashrc hacks, and slow because it's file based on every command, but:

- never delete history

- associate history with a session token

- set separate tokens in each screen, tmux, whatever session

- sort such that backward search (ctrl-R) hits current session history first, and the rest second

Like half my corporate brain is in a 11M history file at this point, going back years.

What I would love is to integrate this into the shell better so it's using sqlite or similar so it doesn't feel "sluggish." But even now the pain is worth the prize.

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by fragmede on Thursday March 26, 2026 @12:15PM (#47532349)
You don't have to setup shared history with Atuin if you don't want to and that's what's holding you back. Otherwise it hits the rest of your requirements. Just don't hesitate to change from the default config.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by commandersaki on Thursday March 26, 2026 @12:39PM (#47532666)
I just want to give a perspective of someone that uses the 'eternal history' in bash per Eli Bandersky [1] and reluctance to use something like atuin (without/ignoring shared history).

First, as for speed and responsiveness, if there is a degradation, it is imperceptible to me. I wouldn't have a clue that my interactive shell is slowing down because it is logging a command to ~/.persistent_history.

My persistent_history is 4MB and has been migrated from machine to machine as I've upgraded, it's never felt slow to edit with (neo)vim or search with system supplied grep.

Eli's way of doing it also includes the timestamps for all commands, so it's easy to trace back when I had run the command, and duplicates are suppressed. In fact my longest persistent_history goes back to 2019-07-04, so I've been using it for quite some time now.

But the larger point I wanted to make is that I wouldn't feel comfortable switching this, in my opinion, quite efficient setup to displace it with an sqlite database. That would require a special tool to drill through the history and search rendering simple unix utilities useless. As Eli suggested, if your history gets too big, simply rotate the file and carry on. I have the alias phgrep to grep ~/.persistent_history, but I can easily have another alias to grep ~/.persistent_history*.

[1]: https://eli.thegreenplace.net/2013/06/11/keeping-persistent-...

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by __MatrixMan__ on Thursday March 26, 2026 @02:56PM (#47534268)
1. work on a project on host_foo in /home/user/src/myproject

2. clone it on host_bar in /home/user/src/myproject

If you set filter_mode = "directory", you can recall project specific commands from host_foo for use on host_bar even though you're working on different machines and the search space won't be cluttered with project specific commands for other projects.

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by doubled112 on Thursday March 26, 2026 @07:13PM (#47537063)
I sync Atuin to my home server but I also configure it to be host specific by default.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by soraminazuki on Thursday March 26, 2026 @01:34PM (#47533347)
Prefix search is faster for the majority of cases. CTRL-r / FZF is useful for the remaining ones.
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by twelvedogs on Thursday March 26, 2026 @07:17PM (#47537089)
If you use multiple terminals it kinda sucks unless you do export PROMPT_COMMAND='history -a' in your.bashrc or something cause only the last closed terminal saves to history
Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by Zetaphor on Thursday March 26, 2026 @07:35PM (#47537237)
Atuin[1] feels like the best of both worlds to me.

[1] https://github.com/atuinsh/atuin

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by annie511266728 on Friday March 27, 2026 @02:31AM (#47539638)
Atuin looks pretty nice — I might give it a try.

I went down the “fully automatic history” path before, but it mostly turned into noise for me.

Keeping a tiny cheatsheet of things I had to look up twice ended up working better.

Re:Shell Tricks That Make Life Easier (and Save Your Sanity) by antonvs on Friday March 27, 2026 @01:50AM (#47539455)
Ctrl-r can’t replace prefix search.