5 ms·
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
by phforms 18d ago
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.
- diath 18d ago> 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".
- weaksauce 18d agoif 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.
- harikb 18d agoClearly I am missing some setting. On zsh on macOS and I tried what you just said and it doesn't work like this
- chrisweekly 18d agoFWIW I'm also on macos 15.7.9, zsh 5.9, oh-my-zsh - and I do get this behavior (TIL). type eg "rg" then up or down arrow, and the history shown is filtered by that rg prefix.
- saghm 18d agoIsn't oh-my-zsh one of those batteries-included distributions? It sounds like that's just one of the configurations that it provides.
- applicative 18d agoI was missing it too. Google says it's a builtin zsh feature but mac doesn't turn it on by default, so you add these to `~/.zshrc` bindkey '^[[A' history-search-backward bindkey '^[[B' history-search-forward So far it works. Thank you diath.
- saghm 18d agoI'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.
- mkehrt 18d agoThis is a readline feature. You can enable it in bash (and other shells?) with: bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward'
- quirino 18d agoatuin 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.
- ChickeNES 18d agoI 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?
- ellieh 18d ago(hi! I work on atuin!) yes, it's improved a lot in the last couple of years! what in particular bothered you?
- saghm 18d agoNot 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.
- ellieh 18d agoAhh yes, we’ve done a lot of performance optimisation since then. We regularly test on >1m records and have no issues 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 18d agoGood to hear! Sounds like my history file might not even be that large compared to your tests now
- dec0dedab0de 18d agoI was my most effective when I had a bunch of cheat sheets taped up in my workspace.
- pards 18d agoHot-desking killed this practice. I now get desk anxiety on my in-office days
- asdfman123 18d agoHave an AI agent compile the cheat sheets into a searchable website hosted on Github for your own personal reference.
- justonenote 18d agoand 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. what a time to be alive.
- UnfitFootprint 18d agoThe 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
- sublinear 18d agoI 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.
- reaperducer 18d agoUsually 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.
- fragmede 18d agohttps://atuin.sh/ https://atuin.sh/
- lelandbatey 18d agoIt'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: https://github.com/lelandbatey/dotfiles/blob/99c08f81fc8971035cc47a1fce3510db3401b26d/.bashrc#L259-L263 https://github.com/lelandbatey/dotfiles/blob/99c08f81fc89710...
- irishcoffee 18d agoYour beef is with git, which is terrible, not a shell.
- wild_egg 18d agoWhat's the point of switching to switch? I've only ever used checkout and not sure what I am missing out on.
- jwpapi 18d agoYou just have to do it so often that you’re annoyed by it and then you learn the shortcut and then you force yourself to always do the shortcut.
- kulahan 18d agoI’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).
- or_am_i 18d agoTemporarily binding the up arrow in the shell to echo "Use Ctrl-R" is probably the quickest way to un-/re-learn
- estetlinus 18d agoI’ve done this, nowadays asking Claude to rebind things so that I’m forced to learn. It comes with interesting side effects!
- jachee 18d agoI learned to type `ls` properly the first time, every time, shortly after installing `sl`.
- RugnirViking 18d agoive just done this, thanks for the suggestion: "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 17d agoI use ctrl-c to abort command entry and start with a clear line.
- gregdeon 18d agoBonus: 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.
- kenniskrag 18d agoYou have a link? :-) (Still a student)
- gregdeon 18d agoMine is unfortunately pretty specific to the HPC clusters we use. Maybe I should pick out the more general bits and make them public some day...
- alexpotato 18d agoI've found Spaced Repetition (via Anki etc) to be great for remembering these things. Was originally turned on to this by Derek Sivers: https://sive.rs/srs https://sive.rs/srs
- delamon 18d agoI have following lines "\e[A": history-search-backward "\e[B": history-search-forward 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.
- lucas_t_a 17d agoon fish shell i never felt the need for any of this, since pressing up does a history search on what you have typed
- bbaron63 17d agoI 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
- MomsAVoxell 17d agoI comment my shell commands, thus: $ ,:(){ :|:& };: #forkbomb 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.