4 ms·
I'm unsure what specific behaviour you want from zsh and the up key, but it provides more than one up-line-*¹² function out of the box. Also, you can add any b
by JNRowe 3y ago
I'm unsure what specific behaviour you want from zsh and the up key, but it provides more than one up-line-*¹² function out of the box. Also, you can add any behaviour you wish with a custom zle function. That said, I understand some people prefer to just use something with the default settings.
¹ https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#index-up_002dline_002dor_002dhistory https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#...
² https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#index-up_002dline_002dor_002dsearch https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#...
- em-bee 3y agoto explain the up key: prompt> some-word[up key] will search for some-word in the history. this feature helps because in 90% of cases i can type some-word and have autosuggestion show me the right command, so i just need to hit right arrow and enter to run it. but, if the suggestion is wrong, i can instead hit up arrow and search for a another history entry. in zsh currently, i can get autosuggestions, but if the suggestions is wrong, i have to type ctrl-A and retype some-word in order to search the history. i want to be able to do that without retyping, the way it is done in fish. elvish only has the uparrop feature which gets me there halfway, i can type something, and then hit uparrow to find a matching command. in most cases the first hit is the one i want, but if not i keep searching. i prefer to also have the autosuggestion because often i don't remember that i have a similar command already, and the autosuggestion provides that hint. together these are the two most useful features that i want from a shell.
- JNRowe 3y agoThat is the difference between the up-line-or-history and up-line-or-search functions that I linked above. The default Up binding is the -history function, whereas the -search function in unbound by default. There are pattern variants too, if you don't like the prefix only checks. If you also need to mimic the fish behaviour of C-r mid-command because your suggestion wasn't correct, then that does need a custom function to bind to C-r as you have to provide ${L,}BUFFER to populate the search pattern like fish does.
- em-bee 3y agoah, thank you. that actually helps a lot. i don't use zsh as much, but it's good to know that this feature is available. i don't use ctrl-R in fish yet, so i won't miss that.
- em-bee 3y agoooops, typo: ctrl-A above is supposed to be ctrl-R, in case anyone is confused