The thing with a lot of these tricks is that you have to get into the habit of using them. I knew `Ctrl+r` for history since I learned about the command line. I even have a nice shell integration with fzf. But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command, because I never remembered the shortcut and just took the path of least resistance to find something.
Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.
> But I still used the up/down arrow keys for years or scrolled up when I was looking for a previous command
It's not even that bad of a habit with zsh either where it will only scroll through history matching a substring in your history, for instance if I type "rg -i" and then start pressing up arrow, it will only cycle through history entries starting with "rg -i".
if you enable history substring search in zsh you can get that feature anywhere in the command and not just the start. it's very useful if you remember some snippet of the command like it had the word debug in it etc. in fish that is built in and on by default.
though one function that i recently added will narrow your history down based on a space separated set of filters which i found useful
function hgrep
set -l cmd history
for pattern in $argv
set cmd "$cmd | grep -- "(string escape "$pattern")
end
eval $cmd | cat
end
use `hgrep ruby debug foo` would filter for a line that contained all the words ruby, debug and foo.
I'm not really sure what "turn it on by default" even means in the context of a shell. I've had that manually in my config for years.
atuin kind of fixes this habit, when you click up you get a list of the latest commands, and you can just start typing to search. It's extremely natural.
I found atuin way too hard/slow to use, I think I went two days before I nuked it and went back to pure omzsh. Has it gotten any better in the past 2ish years?
Not the parent commenter, but I also tried it a year or two ago and my recollection is that I had a similar experience. I have a really long history file that dates back like a decade and if remembering correctly I tried to import it, and it made using my shell very laggy so I ended up removing it. I'm not 100% positive that I'm remembering the exact way that I started experiencing the lag though, so if I have time tomorrow I'll try it out again and see if it's still something I encounter.
I'm curious, is using the daemon with my own frontend a supported use case? Because I had a thought...while as I mentioned above I don't use the CLI much anymore...my agents do, and having that history in a sql db would be mighty useful...
Edit: Okay, y'all are literally working on exactly what I need to build off of, perfect lmao
I think it was a combo of this + completely screwing my muscle memory haha. I'd give it another shot...but tbh, these days claude/codex are more my command line than bash/zsh.
I'm running into this again now that I'm trying it. I also have the unfortunate habit of sometimes trying to do stuff in the terminal via remote connection over a streaming server from my SteamOS handheld, and in the desktop input layout I have defined, I can really easily hit the up arrow with my thumbstick, whereas any modifier shortcuts need to be defined manually. From glancing through the config file, there does seem to be a lot of customization though, so I think it might still be viable if I can find a sweet spot in how to define the settings.
I've been using it happily for longer than that! I do remember having to tweak the default search behaviours when I first installed it but it's been largely problem free ever since.
Or you can start typing and press up arrow to search with that. Atuin (or some Zsh extensions, etc.) fix the bad UI of having to remember a different key for "search history by order and text" and "search history by order".
and hook up a Bluetooth sensor so when you walk into the office it prints them off in individual sticky notes and assigns one of the humanoid robots to collect them and stick them on the monitor or cubicle walls of your chosen work desk.
The printed copy lets you build a spatial association with the command. You are more likely to be able to look up and have your eyes settle roughly where it is than write a query on a custom site.
I think for a digital solution to come close you need it permanently present on a nth monitor
I am young enough that my entire career has been markdown files, screenshots, and photos on my phone. I (a)sync everywhere by pushing git lfs commits to my home server.
Seems like overkill until it saves my ass. It continues to do so almost half a decade into all the LLM hype. It hits the sweet spot between simplicity, convenience, reliability, and precision.
People strongly underestimate how good the git life can be, especially with all the blogspam on here trying to dethrone it lately.
That's a funny (bad faith) angle you took it. I thought were talking about personal cheat sheets for general programming and tools, not work and proprietary stuff.
The alternative and typical options that nobody bats an eye at for doing this kind of thing (3rd-party big tech cloud) are much worse from a data hygiene perspective. If you're going to be that distrustful of personal phone usage by employees, you're running a prison instead of a workplace and replacing all thought with pointless checklists. That slippery slope never ends.
From your perspective, the best security posture is for employees to return to the office without any personal belongings so we can be extra super secure? It's too bad we can't erase their memories while we're at it since being a programmer is knowledge work.
Don't tell any authority that you are doing a thing, unless you have a good reason to tell them. It cannot possibly help you, it can only result in them telling you you can't do the thing any more.
And don't talk to police as a suspect. (I'm not sure if the rule still applies if you are the one reporting a crime)
reminds me of the time when you got strips of fn key binding cheat sheets for various popular software packages like lotus 123 and wordperfect, and keyboards came with a space to hold them.
Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them.
People had this same problem last century. They would use templates that fit over their keyboards with all the common shortcuts and commands printed on them. Sometimes they were for a specific program, but you could buy blank ones to write your own notes.
Today, "keyboard templates" have an entirely different meaning, so the best thing for this is paper. Print your shortcuts out on a piece of paper and put it near your monitor. You could even categorize them by writing them on different-colored Post-Its.
It's quite true. Years ago, after `git switch` was released, I wanted to try to switch from `git checkout` to `git switch`. Ultimately I had to set up some bash nastiness to error and "scold" me when I typed `git checkout` from memory, while still allowing shell scripts to call `git checkout` just fine. It was a fun exercise, and at least now I know how I could do it again: <a href="https://github.com/lelandbatey/dotfiles/blob/99c08f81fc8971035cc47a1fce3510db3401b26d/.bashrc#L259-L263" rel="nofollow">https://github.com/lelandbatey/dotfiles/blob/99c08f81fc89710...
I’ve read that if you’re trying to overturn a habit with a new habit, it’s best to undo whatever it is you did the old way, then redo it the new way.
So if you want to use ctrl-r, but you’re using the up key, use the down key to navigate back to a clear line, then use ctrl-r. Do it enough times and your brain will work overtime to find a shortcut (aka just doing it the new way).
"Use Ctrl-R for fuzzy history, or Ctrl-P/Ctrl-N for history entries"
(I have those bound to bindkey '^P' up-history and bindkey '^N' down-history instead of up and down arrow's "up-line-or-history" which is really annoying with multiline commands)
Bonus: if you write all your tricks in a document, people will love your document. Whenever I offer a new student my CHEATSHEET.md file, their eyes absolutely light up.
in my .inputrc for years. I think, this is how command line worked in tcsh.
It changes unconditional prev/next to prefix search. With empty command line it is the same as the old behavior. But if you enter "ls" and then press up-arrow, it will scroll through all commands in history that have "ls" as a prefix. I use it much more often than C-r.
I probably knew and then forgot the Ctrl+r trick at some point because 99.9% of the time, the up arrow and grepping history is sufficient for my needs. Then again, I don't do that much on the command line anymore
This way, when I want to find it again, I CTRL-R and type ‘forkbomb’ .. voila, instant recall!
All I have to remember is the small ontology I keep in my head for the most important commands I use .. pretty easy if I also construct a narrative for those commands, contextually. “#downup #clearlog #checkconn #amialone #forkbomb”, etc.
phforms · · focus · HN ↗
Usually what I do is writing these tricks down to a document that is easily accessible at a place where I know that I will look for when failing to remember them. I have a directory of docs where I write stuff like this down by language/tool/etc., so I can quickly look it up without having to search the internet. But I also have to actively remind myself that these things exist whenever I have a problem, stop me from just doing the inefficient thing.
diath · · focus · HN ↗
It's not even that bad of a habit with zsh either where it will only scroll through history matching a substring in your history, for instance if I type "rg -i" and then start pressing up arrow, it will only cycle through history entries starting with "rg -i".
weaksauce · · focus · HN ↗
though one function that i recently added will narrow your history down based on a space separated set of filters which i found useful
use `hgrep ruby debug foo` would filter for a line that contained all the words ruby, debug and foo.harikb · · focus · HN ↗
chrisweekly · · focus · HN ↗
type eg "rg" then up or down arrow, and the history shown is filtered by that rg prefix.
saghm · · focus · HN ↗
applicative · · focus · HN ↗
saghm · · focus · HN ↗
mkehrt · · focus · HN ↗
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
quirino · · focus · HN ↗
ChickeNES · · focus · HN ↗
ellieh · · focus · HN ↗
yes, it's improved a lot in the last couple of years! what in particular bothered you?
saghm · · focus · HN ↗
ellieh · · focus · HN ↗
Make sure you’re using the daemon (the install script will handle this) and you should be good to go
Very happy to help if you have any problems. Ellie at Atuin dot sh
saghm · · focus · HN ↗
ChickeNES · · focus · HN ↗
Edit: Okay, y'all are literally working on exactly what I need to build off of, perfect lmao
ellieh · · focus · HN ↗
ChickeNES · · focus · HN ↗
saghm · · focus · HN ↗
zem · · focus · HN ↗
SAI_Peregrinus · · focus · HN ↗
dec0dedab0de · · focus · HN ↗
pards · · focus · HN ↗
asdfman123 · · focus · HN ↗
justonenote · · focus · HN ↗
what a time to be alive.
UnfitFootprint · · focus · HN ↗
I think for a digital solution to come close you need it permanently present on a nth monitor
sublinear · · focus · HN ↗
Seems like overkill until it saves my ass. It continues to do so almost half a decade into all the LLM hype. It hits the sweet spot between simplicity, convenience, reliability, and precision.
People strongly underestimate how good the git life can be, especially with all the blogspam on here trying to dethrone it lately.
guenthert · · focus · HN ↗
Don't let IT hear that unless you work on FOSS.
sublinear · · focus · HN ↗
The alternative and typical options that nobody bats an eye at for doing this kind of thing (3rd-party big tech cloud) are much worse from a data hygiene perspective. If you're going to be that distrustful of personal phone usage by employees, you're running a prison instead of a workplace and replacing all thought with pointless checklists. That slippery slope never ends.
From your perspective, the best security posture is for employees to return to the office without any personal belongings so we can be extra super secure? It's too bad we can't erase their memories while we're at it since being a programmer is knowledge work.
mitxela · · focus · HN ↗
And don't talk to police as a suspect. (I'm not sure if the rule still applies if you are the one reporting a crime)
zem · · focus · HN ↗
reaperducer · · focus · HN ↗
People had this same problem last century. They would use templates that fit over their keyboards with all the common shortcuts and commands printed on them. Sometimes they were for a specific program, but you could buy blank ones to write your own notes.
Today, "keyboard templates" have an entirely different meaning, so the best thing for this is paper. Print your shortcuts out on a piece of paper and put it near your monitor. You could even categorize them by writing them on different-colored Post-Its.
fragmede · · focus · HN ↗
lelandbatey · · focus · HN ↗
irishcoffee · · focus · HN ↗
wild_egg · · focus · HN ↗
jwpapi · · focus · HN ↗
sameerds · · focus · HN ↗
autoexec · · focus · HN ↗
kulahan · · focus · HN ↗
So if you want to use ctrl-r, but you’re using the up key, use the down key to navigate back to a clear line, then use ctrl-r. Do it enough times and your brain will work overtime to find a shortcut (aka just doing it the new way).
or_am_i · · focus · HN ↗
estetlinus · · focus · HN ↗
jachee · · focus · HN ↗
RugnirViking · · focus · HN ↗
"Use Ctrl-R for fuzzy history, or Ctrl-P/Ctrl-N for history entries"
(I have those bound to bindkey '^P' up-history and bindkey '^N' down-history instead of up and down arrow's "up-line-or-history" which is really annoying with multiline commands)
mitxela · · focus · HN ↗
gregdeon · · focus · HN ↗
kenniskrag · · focus · HN ↗
gregdeon · · focus · HN ↗
alexpotato · · focus · HN ↗
Was originally turned on to this by Derek Sivers: <a href="https://sive.rs/srs" rel="nofollow">https://sive.rs/srs
delamon · · focus · HN ↗
It changes unconditional prev/next to prefix search. With empty command line it is the same as the old behavior. But if you enter "ls" and then press up-arrow, it will scroll through all commands in history that have "ls" as a prefix. I use it much more often than C-r.
lucas_t_a · · focus · HN ↗
bbaron63 · · focus · HN ↗
MomsAVoxell · · focus · HN ↗
All I have to remember is the small ontology I keep in my head for the most important commands I use .. pretty easy if I also construct a narrative for those commands, contextually. “#downup #clearlog #checkconn #amialone #forkbomb”, etc.