4 ms·
> 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
by diath 17d 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 17d 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 17d 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 17d 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 16d 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 17d 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 16d 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 16d 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'